#include <bits/stdc++.h>
using namespace std;
int N, M, A, B;
vector<int> g[100101];
vector<pair<int, int> > h[100101];
map<pair<int, int>, int> e;
int dist[100101], p[100101];
long long res[100101];
bool vis[100101];
queue<int> q;
vector<int> w;
void BFS(int S) {
  q.push(S);
  dist[S] = 0;
  while (!q.empty()) {
    int n = q.front();
    q.pop();
    for (int next : g[n]) {
      if (dist[next] != -1) {
        if (dist[next] == dist[n]) A = next, B = n;
        continue;
      }
      q.push(next);
      dist[next] = dist[n] + 1;
      p[next] = n;
    }
  }
}
void DFS(int n) {
  vis[n] = true;
  for (int next : g[n]) {
    if (vis[next]) continue;
    res[next] = e[{min(n, next), max(n, next)}] - res[n];
    DFS(next);
  }
}
long long f(int n, long long val) {
  w.push_back(n);
  vis[n] = true;
  long long ret = abs(val);
  for (auto it : h[n]) {
    int next = it.first;
    long long cost = it.second;
    if (vis[next]) continue;
    ret += f(next, cost - val);
  }
  return ret;
}
void Assign(int n, long long val) {
  vis[n] = true;
  res[n] = val;
  for (auto it : h[n]) {
    int next = it.first;
    long long cost = it.second;
    if (vis[next]) continue;
    Assign(next, cost - val);
  }
}
void ClearW() {
  while (!w.empty()) {
    vis[w.back()] = false;
    w.pop_back();
  }
}
int main() {
  memset(dist, -1, sizeof(dist));
  scanf("%d %d", &N, &M);
  for (int i = 1; i <= M; i++) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    c *= 2;
    if (a > b) swap(a, b);
    if (e.find({a, b}) != e.end()) {
      if (e.find({a, b})->second != c) return !printf("NO");
      continue;
    }
    e[{a, b}] = c;
    g[a].push_back(b);
    g[b].push_back(a);
    h[a].push_back({b, c});
    h[b].push_back({a, c});
  }
  for (int i = 1; i <= N; i++) {
    if (vis[i]) continue;
    A = -1;
    B = -1;
    BFS(i);
    if (A == -1) {
      long long lo = -1234567LL, hi = 1234567LL;
      for (int j = 0; j < 32; j++) {
        long long mid = lo + hi >> 1;
        long long rb = f(i, mid + 1);
        ClearW();
        long long ra = f(i, mid);
        ClearW();
        if (rb - ra < 0)
          lo = mid;
        else
          hi = mid;
      }
      Assign(i, hi);
      continue;
    }
    int X = A;
    long long sum = e[{min(A, B), max(A, B)}];
    vector<pair<int, int> > edg, ea, eb;
    while (A != B) {
      ea.push_back({p[A], A});
      eb.push_back({B, p[B]});
      A = p[A];
      B = p[B];
    }
    reverse(ea.begin(), ea.end());
    for (auto it : eb) edg.push_back(it);
    for (auto it : ea) edg.push_back(it);
    for (int i = 0; i < edg.size(); i++) {
      int a = edg[i].first, b = edg[i].second;
      if (a > b) swap(a, b);
      if (i % 2 == 0)
        sum -= e[{a, b}];
      else
        sum += e[{a, b}];
    }
    assert(sum % 2 == 0);
    sum /= 2;
    res[X] = sum;
    DFS(X);
  }
  for (auto &it : e) {
    if (res[it.first.first] + res[it.first.second] != it.second)
      return !printf("NO");
  }
  printf("YES\n");
  for (int i = 1; i <= N; i++) printf("%.2f ", 1.0 * res[i] / 2);
  return 0;
}
