#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int mod = 1e9 + 7;
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + c - '0', c = getchar();
  return x * f;
}
vector<pair<int, int> > g[N];
int k[N], b[N];
int ans[N];
int vis[N];
vector<int> p;
int main() {
  int n = read(), m = read();
  for (int i = 1; i <= m; i++) {
    int u = read(), v = read(), x = read();
    g[u].push_back(make_pair(v, 2 * x));
    g[v].push_back(make_pair(u, 2 * x));
  }
  vector<int> o;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      p.clear();
      queue<int> q;
      q.push(i);
      p.push_back(i);
      vis[i] = 1, k[i] = 1, b[i] = 0;
      bool cricle = 0;
      int xx = 0;
      while (!q.empty()) {
        int x = q.front();
        q.pop();
        for (pair<int, int> now : g[x]) {
          int to = now.first;
          int w = now.second;
          if (!vis[to]) {
            k[to] = -k[x];
            vis[to] = 1;
            b[to] = w - b[x];
            p.push_back(to);
            q.push(to);
          } else if (!cricle) {
            if (k[to] == -k[x] && b[x] + b[to] != w) {
              puts("NO");
              return 0;
            } else if (k[to] == k[x]) {
              cricle = 1;
              xx = (w - b[x] - b[to]) / (k[to] + k[x]);
            }
          } else {
            if ((w - b[x] - b[to]) != xx * (k[to] + k[x])) {
              puts("NO");
              return 0;
            }
          }
        }
      }
      if (!cricle) {
        o.clear();
        for (int x : p) {
          o.push_back(-k[x] * b[x]);
        }
        sort(o.begin(), o.end());
        xx = o[o.size() / 2];
      }
      for (int x : p) {
        ans[x] = k[x] * xx + b[x];
      }
    }
  }
  cout << "YES\n";
  for (int i = 1; i <= n; ++i) cout << 0.5 * ans[i] << " ";
}
