#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = long double;
using pl = pair<ll, ll>;
using pi = pair<int, int>;
vector<pi> viz[100010];
pi p[100010];
double num[100010];
bool no;
set<int> val;
vector<int> in;
void dfs(int u) {
  in.push_back(u);
  for (auto x : viz[u]) {
    int v = x.first, c = x.second;
    if (p[v].first != 0) {
      if (p[v].first != p[u].first) {
        if ((p[v].second == c - p[u].second))
          continue;
        else
          no = true;
      }
      if (p[v].first == p[u].first) {
        val.insert((c - p[v].second - p[u].second) * p[v].first);
      }
    } else {
      p[v].first = -p[u].first;
      p[v].second = c - p[u].second;
      dfs(v);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    viz[a].push_back({b, c});
    viz[b].push_back({a, c});
  }
  no = false;
  for (int i = 1; i <= n; i++) {
    if (p[i].first == 0) {
      val.clear();
      in.clear();
      p[i] = {1, 0};
      dfs(i);
      if (val.size() > 1) no = true;
      if (val.size() == 0) {
        vector<int> fd;
        for (auto x : in) fd.push_back(p[x].first * p[x].second);
        sort(begin(fd), end(fd));
        int c = -fd[fd.size() / 2];
        for (auto x : in) num[x] = (double)p[x].first * c + p[x].second;
      } else {
        double c = (double)*val.begin() / 2;
        for (auto x : in) num[x] = (double)p[x].first * c + p[x].second;
      }
    }
  }
  if (no)
    cout << "NO" << endl;
  else {
    cout << "YES" << endl;
    for (int i = 1; i <= n; i++) cout << num[i] << ' ';
    cout << endl;
  }
}
