#include <bits/stdc++.h>
using namespace std;
long long int n, m;
long long int arr[300000];
vector<array<long long int, 2>> adj[300000];
set<long long int> nodes;
bool visited[300000];
vector<long double> vec;
long double brr[300000];
long double crr[300000];
long double chan;
bool dfs(long long int node, long double val, long long int cof) {
  visited[node] = true;
  nodes.insert(node);
  brr[node] = val;
  if (cof == 1)
    crr[node] = -val;
  else
    crr[node] = val;
  for (auto it : adj[node]) {
    if (!visited[it[0]]) {
      if (!dfs(it[0], it[1] - val, 1 - cof)) return false;
    } else {
      if (brr[it[0]] != it[1] - val) {
        chan = (brr[it[0]] - it[1] + val) / 2.0;
        return false;
      }
    }
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int TESTS, q, a, b, l, r, c, k, p, h, w, x, y, z, xs, ys, t, f;
  long double d;
  TESTS = 1;
  memset(visited, false, sizeof(visited));
  while (TESTS--) {
    cin >> n >> m;
    for (long long int i = 0; i <= m - 1; i++) {
      cin >> a >> b >> c;
      a--;
      b--;
      adj[a].push_back({b, c});
      if (a != b) adj[b].push_back({a, c});
    }
    for (long long int i = 0; i <= n - 1; i++) {
      if (!visited[i]) {
        if (dfs(i, 0, 1)) {
          for (auto it : nodes) visited[it] = false;
          for (auto it : nodes) vec.push_back(crr[it]);
          sort(vec.begin(), vec.end());
          if (!dfs(i, vec[vec.size() / 2], 1)) {
            for (auto it : nodes) visited[it] = false;
            dfs(i, 0, 1);
          }
        } else {
          for (auto it : nodes) visited[it] = false;
          long double cha = chan;
          if (!dfs(i, cha, 1)) {
            for (auto it : nodes) visited[it] = false;
            if (!dfs(i, -cha, 1)) {
              cout << "NO\n";
              return 0;
            }
          }
        }
        nodes.clear();
        vec.clear();
      }
    }
    cout << "YES\n";
    for (long long int i = 0; i <= n - 1; i++) cout << brr[i] << " ";
  }
  return 0;
}
