#include <bits/stdc++.h>
using namespace std;
vector<int> v[102], divisor;
int lcm[102][102], gcd[102][102], res[102];
bool flag, visited[102][102], vis[102];
void findDivisiors(int x) {
  for (int i = 1; i <= (int)(ceil(sqrt(x))); i++) {
    if (x % i == 0) {
      divisor.push_back(i);
      if (i != x / i) divisor.push_back(x / i);
    }
  }
}
int findGCD(int a, int b) {
  if (b == 0) return a;
  return findGCD(b, a % b);
}
void dfs(int u, int num) {
  long long multiple;
  int i;
  for (i = 0; i < v[u].size(); i++) {
    if (flag) break;
    if (!visited[u][v[u][i]]) {
      visited[u][v[u][i]] = true;
      multiple = (long long)gcd[u][v[u][i]] * (long long)lcm[u][v[u][i]];
      if (multiple % num != 0 ||
          findGCD(num, multiple / num) != gcd[u][v[u][i]]) {
        flag = true;
        break;
      }
      dfs(v[u][i], multiple / num);
    }
  }
  res[u] = num;
  vis[u] = true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, i, j, x, y, l, g;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> x >> y >> g >> l;
    v[x].push_back(y);
    v[y].push_back(x);
    gcd[x][y] = g;
    gcd[y][x] = g;
    lcm[x][y] = l;
    lcm[y][x] = l;
  }
  memset(res, 0, sizeof(res));
  memset(vis, false, sizeof(vis));
  for (i = 1; i <= n; i++) {
    if (!vis[i] && v[i].size()) {
      findDivisiors(lcm[v[i][0]][i]);
      for (j = 0; j < divisor.size(); j++) {
        flag = false;
        memset(visited, false, sizeof(visited));
        dfs(i, divisor[j]);
        if (!flag) break;
      }
      if (flag) {
        cout << "NO\n";
        return 0;
      }
      divisor.clear();
    }
  }
  cout << "YES\n";
  for (i = 1; i <= n; i++) {
    if (!res[i])
      cout << 1 << " ";
    else
      cout << res[i] << " ";
  }
  cout << endl;
  return 0;
}

### Prompt

Create a solution in Cpp for the following problem:

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 106.

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 ≤ 106).

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.

Examples

Input

1 0


Output

YES
1 

Input

2 1
1 2 1 3


Output

YES
1 3 

Input

3 2
3 2 1 2
3 1 1 10


Output

YES
5 1 2 

Input

2 1
1 2 3 7


Output

NO

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<int> v[102], divisor;
int lcm[102][102], gcd[102][102], res[102];
bool flag, visited[102][102], vis[102];
void findDivisiors(int x) {
  for (int i = 1; i <= (int)(ceil(sqrt(x))); i++) {
    if (x % i == 0) {
      divisor.push_back(i);
      if (i != x / i) divisor.push_back(x / i);
    }
  }
}
int findGCD(int a, int b) {
  if (b == 0) return a;
  return findGCD(b, a % b);
}
void dfs(int u, int num) {
  long long multiple;
  int i;
  for (i = 0; i < v[u].size(); i++) {
    if (flag) break;
    if (!visited[u][v[u][i]]) {
      visited[u][v[u][i]] = true;
      multiple = (long long)gcd[u][v[u][i]] * (long long)lcm[u][v[u][i]];
      if (multiple % num != 0 ||
          findGCD(num, multiple / num) != gcd[u][v[u][i]]) {
        flag = true;
        break;
      }
      dfs(v[u][i], multiple / num);
    }
  }
  res[u] = num;
  vis[u] = true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, i, j, x, y, l, g;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> x >> y >> g >> l;
    v[x].push_back(y);
    v[y].push_back(x);
    gcd[x][y] = g;
    gcd[y][x] = g;
    lcm[x][y] = l;
    lcm[y][x] = l;
  }
  memset(res, 0, sizeof(res));
  memset(vis, false, sizeof(vis));
  for (i = 1; i <= n; i++) {
    if (!vis[i] && v[i].size()) {
      findDivisiors(lcm[v[i][0]][i]);
      for (j = 0; j < divisor.size(); j++) {
        flag = false;
        memset(visited, false, sizeof(visited));
        dfs(i, divisor[j]);
        if (!flag) break;
      }
      if (flag) {
        cout << "NO\n";
        return 0;
      }
      divisor.clear();
    }
  }
  cout << "YES\n";
  for (i = 1; i <= n; i++) {
    if (!res[i])
      cout << 1 << " ";
    else
      cout << res[i] << " ";
  }
  cout << endl;
  return 0;
}

```