Codeforces Beta Round 56
C
Mushroom Strife
Codeforces
2100
原题
← BD →
翻译中…

Pasha and Akim were making a forest map — the lawns were the graph's vertexes and the roads joining the lawns were its edges. They decided to encode the number of laughy mushrooms on every lawn in the following way: on every edge between two lawns they wrote two numbers, the greatest common divisor (GCD) and the least common multiple (LCM) of the number of mushrooms on these lawns. But one day Pasha and Akim had an argument about the laughy mushrooms and tore the map. Pasha was left with just some part of it, containing only $*m*$ roads. Your task is to help Pasha — use the map he has to restore the number of mushrooms on every lawn. As the result is not necessarily unique, help Pasha to restore any one or report that such arrangement of mushrooms does not exist. It is guaranteed that the numbers on the roads on the initial map were no less that $1$ and did not exceed $10^{6}$.

翻译中…

Input

翻译中…

The first line contains two numbers $*n*$ and $*m*$ (image) which are the numbers of lawns and roads we know about. Each of the following $*m*$ lines contains four numbers which are the numbers of lawns the road connects, the GCD and the LCM of the numbers of mushrooms on these lawns ($1 ≤ *GCD*, *LCM* ≤ 10^{6}$).

翻译中…

It is guaranteed, that no road connects lawn to itself, and no two lawns are connected by more than one road.

翻译中…

Output

翻译中…

The answer should contain "YES" or "NO" on the first line, saying whether it is possible or not to perform the arrangement. If the answer is "YES", print on the following line $*n*$ numbers which are the numbers of mushrooms on the corresponding lawns.

翻译中…

样例

Input #1
1 0
Output #1
YES
1
InputCopy OutputCopy
Input #2
2 1
1 2 1 3
Output #2
YES
1 3
InputCopy OutputCopy
Input #3
3 2
3 2 1 2
3 1 1 10
Output #3
YES
5 1 2
InputCopy OutputCopy
Input #4
2 1
1 2 3 7
Output #4
NO
InputCopy OutputCopy
题目信息
题号
60C
时间限制
2 s
内存限制
256 MB
标签
暴力
DFS 及类似

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。