#include <bits/stdc++.h>
using namespace std;
inline char gc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline long long read() {
  long long x = 0;
  char ch = getchar();
  bool positive = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') positive = 0;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return positive ? x : -x;
}
inline void write(long long a) {
  if (a < 0) {
    a = -a;
    putchar('-');
  }
  if (a >= 10) write(a / 10);
  putchar('0' + a % 10);
}
inline void writeln(long long a) {
  write(a);
  puts("");
}
inline void wri(long long a) {
  write(a);
  putchar(' ');
}
long long rnd() {
  unsigned long long ans = 0;
  for (int i = (int)(0); i <= (int)(4); i++) ans = ans << 15 ^ rand();
  return ans % ((unsigned long long)1 << 63);
}
const int N = 100005;
const long double eps = 1e-9;
long double A[N], B[N], ans[N];
int n, m;
vector<long double> ab, f;
vector<int> g;
vector<pair<long long, long long> > v[N];
void GG() {
  puts("NO");
  exit(0);
}
void dfs(int p, int a, int b) {
  if (!A[p]) {
    A[p] = a;
    B[p] = b;
  } else if (A[p] != a || B[p] != b) {
    if (A[p] == a) GG();
    ab.push_back((long double)(b - B[p]) / (A[p] - a));
    return;
  } else
    return;
  f.push_back(a * b);
  g.push_back(p);
  for (auto i : v[p]) {
    dfs(i.first, -a, i.second - b);
  }
}
int main() {
  n = read();
  m = read();
  for (int i = (int)(1); i <= (int)(m); i++) {
    int s = read(), t = read(), w = read();
    v[s].push_back(make_pair(t, w));
    v[t].push_back(make_pair(s, w));
  }
  for (int i = (int)(1); i <= (int)(n); i++)
    if (!A[i]) {
      ab.clear();
      f.clear();
      g.clear();
      dfs(i, 1, 0);
      if (ab.size()) {
        for (int i = (int)(1); i <= (int)(ab.size() - 1); i++)
          if (fabs(ab[i] - ab[i - 1]) > eps) GG();
        for (auto i : g) ans[i] = A[i] * ab[0] + B[i];
      } else {
        sort(f.begin(), f.end());
        long double x = -f[f.size() / 2];
        for (auto i : g) ans[i] = A[i] * x + B[i];
      }
    }
  puts("YES");
  for (int i = (int)(1); i <= (int)(n - 1); i++)
    printf("%.10f ", (double)ans[i]);
  printf("%.10f", (double)ans[n]);
}
