#include <bits/stdc++.h>
using namespace std;
void dfs(int u, vector<vector<pair<int, int>>>& graph, vector<int>& color,
         vector<vector<int>>& f, vector<int>& vertices, int& found, double& x) {
  vertices.emplace_back(u);
  for (pair<int, int> v : graph[u]) {
    if (!color[v.first]) {
      color[v.first] = color[u] ^ 3;
      f[v.first] = {-f[u][0], v.second - f[u][1]};
      dfs(v.first, graph, color, f, vertices, found, x);
    } else if (color[u] == color[v.first]) {
      found = u;
      x = (double)(v.second - f[v.first][1] - f[u][1]) /
          (f[u][0] + f[v.first][0]);
    }
  }
}
void dfs_found(int u, vector<vector<pair<int, int>>>& graph, vector<bool>& vis,
               vector<double>& ans) {
  vis[u] = true;
  for (pair<int, int> v : graph[u]) {
    if (!vis[v.first]) {
      ans[v.first] = v.second - ans[u];
      dfs_found(v.first, graph, vis, ans);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<pair<int, int>>> graph(n + 1);
  for (int i = 0; i < m; ++i) {
    int u, v, w;
    cin >> u >> v >> w;
    graph[u].emplace_back(make_pair(v, w));
    graph[v].emplace_back(make_pair(u, w));
  }
  vector<int> color(n + 1);
  vector<vector<int>> f(n + 1, vector<int>(2));
  vector<bool> vis(n + 1);
  vector<double> ans(n + 1);
  for (int u = 1; u <= n; ++u) {
    if (!color[u]) {
      color[u] = 1;
      f[u] = {1, 0};
      vector<int> vertices;
      int found = 0;
      double x;
      dfs(u, graph, color, f, vertices, found, x);
      if (found) {
        ans[found] = f[found][0] * x + f[found][1];
        dfs_found(found, graph, vis, ans);
      } else {
        vector<int> b;
        for (int v : vertices) {
          b.emplace_back(-f[v][0] * f[v][1]);
        }
        sort(b.begin(), b.end());
        x = b.size() % 2 == 1
                ? b[(b.size() - 1) / 2]
                : (double)(b[b.size() / 2 - 1] + b[b.size() / 2]) / 2;
        for (int v : vertices) {
          ans[v] = f[v][0] * x + f[v][1];
        }
      }
    }
  }
  bool nope = false;
  for (int u = 1; u <= n; ++u) {
    for (pair<int, int> v : graph[u]) {
      if (abs(ans[u] + ans[v.first] - v.second) > 1e-8) {
        nope = true;
      }
    }
  }
  if (nope) {
    cout << "NO";
  } else {
    cout << "YES" << '\n';
    for (int u = 1; u <= n; ++u) {
      cout << ans[u] << ' ';
    }
  }
  return 0;
}
