#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
const int M = N << 1;
bool vis[N];
pair<int, int> val[N];
vector<pair<int, int> > g[N];
int ans[N];
pair<int, int> solve(const pair<int, int> &p, const pair<int, int> &q) {
  int a = p.first, b = p.second, c = q.first, d = q.second;
  if (a == c && b == d) return {2, 0};
  if (a == c && b != d) return {0, 0};
  return {1, (d - b) / (a - c)};
}
int x_value;
bool x_decided;
vector<int> visited_nodes;
bool dfs(int x, pair<int, int> v) {
  if (0) printf("visit %d: val = %d * x + %d\n", x, v.first, v.second);
  vis[x] = true;
  val[x] = v;
  int a = v.first, b = v.second;
  visited_nodes.push_back(x);
  for (auto node : g[x]) {
    int y = node.first;
    int z = node.second;
    if (0) printf("visit edge(%d -> %d)\n", x, y);
    pair<int, int> nex = {-a, z - b};
    if (vis[y]) {
      auto res = solve(nex, val[y]);
      if (res.first == 0) return false;
      if (res.first == 2) continue;
      if (x_decided) {
        if (x_value != res.second) return false;
      } else {
        x_decided = true;
        x_value = res.second;
      }
      continue;
    }
    if (!dfs(y, nex)) return false;
  }
  return true;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) g[i].clear();
  for (int i = 1; i <= m; ++i) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    g[x].emplace_back(y, z << 1);
    g[y].emplace_back(x, z << 1);
  }
  for (int i = 1; i <= n; ++i) {
    if (vis[i]) continue;
    visited_nodes.clear();
    x_decided = false;
    if (!dfs(i, {1, 0})) {
      puts("NO");
      return 0;
    }
    if (!x_decided) {
      static vector<int> nums;
      nums.clear();
      for (auto node : visited_nodes)
        nums.push_back(val[node].second * (val[node].first > 0 ? -1 : 1));
      sort(nums.begin(), nums.end());
      x_value = nums[(nums.size() - 1) / 2];
    }
    for (auto node : visited_nodes)
      ans[node] = val[node].first * x_value + val[node].second;
  }
  puts("YES");
  for (int i = 1; i <= n; ++i) {
    if (ans[i] % 2 == 0)
      printf("%d", ans[i] / 2);
    else if (ans[i] == -1)
      printf("-0.5");
    else
      printf("%d.5", ans[i] / 2);
    printf("%c", " \n"[i == n]);
  }
  return 0;
}
