#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
const int INF = 1e9 + 7;
int n, m;
vector<pair<int, int>> g[N];
pair<int, int> ca[N];
bool used[N];
vector<int> cur;
int x;
void dfs(int v, int s, int c) {
  used[v] = true;
  cur.push_back(v);
  ca[v] = {s, c};
  for (auto e : g[v]) {
    if (!used[e.first]) {
      if (e.second == 0) {
        dfs(e.first, -s, 1 - c);
      } else {
        dfs(e.first, -s, 2 - c);
      }
    } else {
      int ns = -s;
      int nc = (e.second == 0 ? 1 - c : 2 - c);
      if (ns == ca[e.first].first) {
        if (nc != ca[e.first].second) {
          cout << "NO\n";
          exit(0);
        }
      } else {
        int nx = (nc - ca[e.first].second) / ((ca[e.first].first - ns) / 2);
        if (x != INF && x != nx) {
          cout << "NO\n";
          exit(0);
        }
        x = nx;
      }
    }
  }
}
long double ans[N];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout.precision(47);
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int v, u, c;
    cin >> v >> u >> c;
    --v, --u, --c;
    g[v].push_back({u, c});
    g[u].push_back({v, c});
  }
  for (int v = 0; v < n; ++v) {
    if (!used[v]) {
      cur.clear();
      x = INF;
      dfs(v, 1, 0);
      if (x == INF) {
        sort(cur.begin(), cur.end(), [&](int a, int b) {
          return -ca[a].first * ca[a].second < -ca[b].first * ca[b].second;
        });
        int v = cur[(int)cur.size() / 2];
        x = 2 * (-ca[v].first * ca[v].second);
      }
      for (int u : cur) {
        ans[u] = (long double)(ca[u].first * x) / 2 + ca[u].second;
      }
    }
  }
  cout << "YES\n";
  for (int v = 0; v < n; ++v) {
    cout << ans[v] << ' ';
  }
  cout << '\n';
  return 0;
}
