#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
using ll = long long;
using namespace std;
string to_string(string s) { return s; }
string to_string(bool b) { return b ? "true" : "false"; }
string to_string(char c) { return string(1, c); }
string to_string(const char *s) { return (string)s; }
template <class A, class B>
string to_string(pair<A, B>);
template <class T>
string to_string(T v) {
  string s = "{", sep = "";
  for (auto x : v) {
    s += sep;
    sep = ", ";
    s += to_string(x);
  }
  return s + "}";
}
template <class A, class B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void dbgPrint() { cerr << endl; }
template <class A, class... B>
void dbgPrint(A a, B... b) {
  cerr << ' ' << to_string(a);
  dbgPrint(b...);
}
namespace IO {
template <class A, class B>
ostream &operator<<(ostream &out, vector<pair<A, B>> a);
template <class A>
ostream &operator<<(ostream &out, vector<A> a);
template <class A, class B>
ostream &operator<<(ostream &out, pair<A, B> a) {
  out << a.first << " " << a.second;
  return out;
}
template <class A, class B>
ostream &operator<<(ostream &out, vector<pair<A, B>> a) {
  for (pair<A, B> x : a) out << x.first << " " << x.second << '\n';
  return out;
}
template <class A>
ostream &operator<<(ostream &out, vector<A> a) {
  for (A x : a) out << x << ' ';
  return out;
}
template <class A, class B>
istream &operator>>(istream &in, pair<A, B> &a) {
  in >> a.first >> a.second;
  return in;
}
template <class A>
istream &operator>>(istream &in, vector<A> &a) {
  for (A &x : a) in >> x;
  return in;
}
}  // namespace IO
template <class A, class B>
inline ll chkmax(A &a, B b) {
  if (a < (A)b) {
    a = (A)b;
    return 1;
  }
  return 0;
}
template <class A, class B>
inline ll chkmin(A &a, B b) {
  if (a > (A)b) {
    a = (A)b;
    return 1;
  }
  return 0;
}
using namespace IO;
void solve();
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(41);
  ll q = 1;
  while (q--) solve();
}
const ll N = 1e5 + 2;
vector<ll> g1[N];
vector<ll> g2[N];
ll comp[N];
pair<ll, ll> res[N];
const ll BUB = 1e13;
ll f = 1;
vector<ll> tour;
ll u[N];
bool can = true;
bool is_0 = false;
ll val = BUB;
void dfs1(ll v) {
  u[v] = 1;
  tour.emplace_back(v);
  ;
  for (ll x : g1[v]) {
    if (u[x]) {
      if (res[x].second + res[v].second == 2 &&
          res[x].first + res[v].first == 0)
        continue;
      if (res[x].second + res[v].second != 2 &&
          res[x].first + res[v].first == 0) {
        ;
        can = false;
      }
      if (res[x].first + res[v].first != 0 && val == BUB)
        val = (2 - (res[x].second + res[v].second)) /
              (res[x].first + res[v].first);
    } else {
      res[x].first = -res[v].first;
      res[x].second = 2 - res[v].second;
      dfs1(x);
    }
  }
  for (ll x : g2[v]) {
    if (u[x]) {
      if (res[x].second + res[v].second == 4 &&
          res[x].first + res[v].first == 0)
        continue;
      if (res[x].second + res[v].second != 4 &&
          res[x].first + res[v].first == 0) {
        ;
        can = false;
      }
      if (res[x].first + res[v].first != 0 && val == BUB)
        val = (4 - (res[x].second + res[v].second)) /
              (res[x].first + res[v].first);
    } else {
      res[x].first = -res[v].first;
      res[x].second = 4 - res[v].second;
      dfs1(x);
    }
  }
}
ll u2[N];
ll ans[N];
void dfs2(ll v) {
  u2[v] = 1;
  for (ll x : g1[v]) {
    if (!u2[x]) {
      ans[x] = 2 - ans[v];
      dfs2(x);
    }
  }
  for (ll x : g2[v]) {
    if (!u2[x]) {
      ans[x] = 4 - ans[v];
      dfs2(x);
    }
  }
}
void solve() {
  ll n, m;
  cin >> n >> m;
  vector<vector<ll>> eds;
  for (ll i = (0); i < (ll)(m); ++i) {
    ll a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    eds.push_back({a, b, c});
    if (c == 1) {
      g1[b].emplace_back(a);
      g1[a].emplace_back(b);
    } else {
      g2[a].emplace_back(b);
      g2[b].emplace_back(a);
    }
  }
  ll INF = 2e9;
  for (ll i = (0); i < (ll)(n); ++i) {
    if (!u[i]) {
      res[i].first = 1;
      can = true;
      is_0 = false;
      val = BUB;
      f = 1;
      tour.clear();
      dfs1(i);
      ;
      if (!can) {
        cout << ("NO") << '\n';
        return;
      }
      if (val != BUB) {
        ans[i] = val;
        dfs2(i);
        continue;
      }
      vector<ll> vals;
      for (ll x : tour) {
        vals.emplace_back(-res[x].first * res[x].second);
      }
      sort((vals).begin(), (vals).end());
      ans[i] = vals[((ll)(vals).size()) / 2];
      dfs2(i);
    }
  }
  for (auto t : eds) {
    if (ans[t[0]] + ans[t[1]] != t[2] * 2) {
      cout << ("NO") << '\n';
      return;
    }
  }
  cout << ("YES") << '\n';
  for (ll i = (0); i < (ll)(n); ++i) cout << ans[i] / 2.0 << " ";
}
