#include <bits/stdc++.h>   using namespace std;   template <typename Arg1>   void __f(const char* name, Arg1&& arg1) {     cout << name <<   :   << arg1 << std::endl;   }   template <typename Arg1, typename... Args>   void __f(const char* names, Arg1&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     cout.write(names, comma - names) <<   :   << arg1 <<   |  ;     __f(comma + 1, args...);   }   const int MAXN = 100005;   const int SQRTN = 1003;   const int LOGN = 22;   const double PI = acos(-1);   const int INF = 1e9;   const int MOD = 1000000007;   const int FMOD = 998244353;   const double eps = 1e-8;   void solvethetestcase();   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t = 1;     for (int testcase = 1; testcase < t + 1; testcase++) {       solvethetestcase();     }   }   int n, m;   vector<pair<int, int> > adj[MAXN];   bitset<MAXN> vis;   double ans[MAXN];   bool flag = 1;   int par[MAXN], dep[MAXN];   int pw[MAXN];   int sm[MAXN];   map<int, int> freq;   vector<int> cc;   void dfs(int u, double val) {     ans[u] = val;     for (auto v : adj[u]) {       if (par[v.first] == u and v.first != u) {         dfs(v.first, v.second - val);       }     }   }   void bfs(int root) {     dep[root] = 0;     par[root] = root;     sm[root] = 0;     queue<int> q;     q.push(root);     while (q.size()) {       int u = q.front();       q.pop();       vis[u] = 1;       cc.push_back(u);       for (auto v : adj[u]) {         if (dep[v.first] == MAXN) {           par[v.first] = u;           pw[v.first] = v.second;           dep[v.first] = 1 + dep[u];           if (dep[u] % 2 == 0)             sm[v.first] = sm[u] + v.second;           else             sm[v.first] = sm[u] - v.second;           q.push(v.first);         }       }     }     double minoddshit = INF, maxoddshit = -INF;     freq.clear();     for (auto u : cc) {       freq[sm[u]]++;       for (auto v : adj[u]) {         if (v.first != u and (dep[v.first] + 1 == dep[u] or par[v.first] == u))           continue;         if (dep[v.first] == dep[u]) {           double val;           if (dep[u] % 2 == 0) {             val = (double)(sm[v.first] - sm[u] + v.second) / (double)2 +                   (double)sm[u];           } else {             val = (double)(sm[v.first] - sm[u] - v.second) / (double)2 +                   (double)sm[u];           }           minoddshit = min(minoddshit, val);           maxoddshit = max(maxoddshit, val);           if (minoddshit + eps < maxoddshit) {             flag = 0;             return;           }         } else {           if (dep[u] % 2 == 1) {             if (sm[u] - v.second == sm[v.first]) continue;             flag = 0;             return;           } else {             if (sm[u] + v.second == sm[v.first]) continue;             flag = 0;             return;           }         }       }     }     if (minoddshit != INF) {       dfs(root, minoddshit);       return;     }     int neg = 0, zer = 0, pos = 0, cur = 0;     for (auto x : freq) {       if (x.first == 0)         zer += x.second;       else if (x.first > 0)         pos += x.second;       else         neg += x.second;     }     while (pos + zer < neg) {       pos += zer;       cur--;       zer = freq[cur];       neg -= zer;     }     while (neg + zer < pos) {       neg += zer;       cur++;       zer = freq[cur];       pos -= zer;     }     dfs(root, cur);   }   void solvethetestcase() {     cin >> n >> m;     for (int i = 0; i < m; i++) {       int u, v, w;       cin >> u >> v >> w;       adj[u].push_back({v, w});       adj[v].push_back({u, w});     }     for (int i = 1; i < n + 1; i++) {       sort(adj[i].begin(), adj[i].end());       for (int j = 0; j + 1 < adj[i].size(); j++) {         if (adj[i][j].first == adj[i][j + 1].first and             adj[i][j].second != adj[i][j + 1].second) {           cout <<  NO n ;           return;         }       }     }     for (int i = 1; i < n + 1; i++) dep[i] = MAXN;     for (int i = 1; i < n + 1; i++) {       if (!vis[i]) {         bfs(i);         cc.clear();         if (!flag) break;       }     }     if (!flag) {       cout <<  NO n ;     } else {       cout <<  YES n ;       for (int i = 1; i < n + 1; i++) cout << ans[i] <<    ;       cout <<   n ;     }   }