#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, m, used[N], d[N];
long double val, a[N];
vector<pair<int, int>> g[N];
vector<pair<int, long double>> vals;
set<long double> x;
void dfs(int v) {
  vals.push_back(make_pair(v, a[v]));
  used[v] = 1;
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i].first;
    int val = g[v][i].second;
    if (used[to]) {
      if (d[v] != d[to]) {
        if (a[v] + a[to] != val) {
          cout << "NO" << endl;
          exit(0);
        }
      } else {
        long double X = (val - a[v] - a[to]) / 2.;
        if (d[v] == 0)
          x.insert(X);
        else
          x.insert(-X);
      }
      continue;
    }
    d[to] = d[v] ^ 1;
    a[to] = val - a[v];
    dfs(to);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  while (m--) {
    int a, b, c;
    cin >> a >> b >> c;
    g[a].push_back(make_pair(b, c));
    g[b].push_back(make_pair(a, c));
  }
  for (int i = 1; i <= n; i++) {
    if (used[i]) continue;
    x.clear();
    vals.clear();
    dfs(i);
    if (x.size() > 1) {
      cout << "NO" << endl;
      exit(0);
    }
    long double X = 0;
    if (!x.empty())
      X = *x.begin();
    else {
      for (int j = 0; j < vals.size(); j++)
        if (!d[vals[j].first]) vals[j].second *= -1;
      sort(vals.begin(), vals.end(),
           [](pair<int, long double> a, pair<int, long double> b) {
             return a.second < b.second;
           });
      X = vals[vals.size() / 2].second;
    }
    for (int j = 0; j < vals.size(); j++)
      if (!d[vals[j].first])
        a[vals[j].first] += X;
      else
        a[vals[j].first] -= X;
  }
  cout << "YES" << endl;
  for (int i = 1; i <= n; i++) cout << a[i] << " ";
  cout << endl;
  return 0;
}
