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
#include <bits/stdc++.h>
using namespace std;
vector<int> primes;
long long gcd(long long a, long long b) {
  if (b > a) return gcd(b, a);
  while (b) {
    long long mod = a % b;
    a = b;
    b = mod;
  }
  return a;
}
void gen_primes(int n) {
  vector<int> bit(n + 1, 1);
  primes.push_back(2);
  int lim = sqrt(n) + 1;
  for (int i = 3; i <= n; i += 2) {
    if (bit[i]) {
      primes.push_back(i);
      if (i > lim) continue;
      for (int j = i * i; j <= n; j += i) bit[j] = 0;
    }
  }
}
void prime_division(long long n, vector<pair<long long, long long> > &facts) {
  for (int i = 0; i < primes.size(); ++i) {
    int cnt = 0;
    int p = primes[i];
    while (n % p == 0) {
      cnt++;
      n /= p;
    }
    if (cnt) facts.push_back(make_pair(p, cnt));
    if (n == 1) break;
  }
  if (n > 1) facts.push_back(make_pair(n, 1));
}
void divisors(const vector<pair<long long, long long> > &facts,
              vector<long long> &divs) {
  divs.push_back(1);
  for (int i = 0; i < facts.size(); ++i) {
    vector<long long> tmp;
    long long p = facts[i].first;
    long long acc = p;
    for (long long j = 1; j <= facts[i].second; ++j) {
      for (int k = 0; k < divs.size(); ++k) tmp.push_back(divs[k] * acc);
      acc *= p;
    }
    divs.insert(divs.end(), tmp.begin(), tmp.end());
  }
}
bool find_mus(const vector<vector<pair<long long, long long> > > &v,
              const set<int> &cn, vector<long long> &table) {
  int N = v.size();
  int start = *cn.begin();
  int to = 0;
  for (to = 0; to < N; ++to)
    if (v[start][to].first != 0) break;
  long long pr = v[start][to].first * v[start][to].second;
  if (cn.size() == 1) return true;
  vector<pair<long long, long long> > facts;
  vector<long long> divs;
  prime_division(pr, facts);
  divisors(facts, divs);
  for (vector<long long>::iterator it = divs.begin(); it != divs.end(); ++it) {
    queue<int> q;
    vector<int> used(N, 0);
    q.push(start);
    table[start] = *it;
    used[start] = 1;
    bool found = true;
    while (!q.empty()) {
      int n = q.front();
      q.pop();
      for (int i = 0; i < N; ++i) {
        if (v[n][i].first != 0) {
          long long pr = v[n][i].first * v[n][i].second;
          if (pr % table[n] != 0) {
            found = false;
            goto next;
          }
          if (used[i] && table[i] != pr / table[n]) {
            found = false;
            goto next;
          }
          table[i] = pr / table[n];
          if (gcd(table[i], table[n]) != v[n][i].first) {
            found = false;
            goto next;
          }
          if (!used[i]) q.push(i);
          used[i] = 1;
        }
      }
    }
  next:
    if (found) return true;
  }
  return false;
}
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<pair<long long, long long> > > v(
      N, vector<pair<long long, long long> >(N, make_pair(0, 0)));
  gen_primes(1000000);
  for (int i = 0; i < M; ++i) {
    int a, b;
    pair<long long, long long> p;
    cin >> a >> b >> p.first >> p.second;
    --a;
    --b;
    v[a][b] = v[b][a] = p;
  }
  vector<set<int> > connections;
  vector<int> used(N, 0);
  while (true) {
    set<int> s;
    queue<int> q;
    int start = 0;
    for (start = 0; start < N; ++start)
      if (!used[start]) break;
    if (start == N) break;
    q.push(start);
    used[start] = 1;
    while (!q.empty()) {
      int n = q.front();
      q.pop();
      s.insert(n);
      for (int i = 0; i < N; ++i) {
        if (!used[i] && v[n][i].first != 0) {
          q.push(i);
          used[i] = 1;
        }
      }
    }
    connections.push_back(s);
  }
  vector<long long> table(N, 1);
  bool found = true;
  for (int i = 0; i < connections.size(); ++i) {
    if (!find_mus(v, connections[i], table)) {
      found = false;
      break;
    }
  }
  if (found) {
    cout << "YES" << endl;
    for (int i = 0; i < N; ++i) cout << table[i] << " ";
    cout << endl;
  } else
    cout << "NO" << endl;
  return 0;
}
