#include <bits/stdc++.h>
using namespace std;
const int INF = 100000000;
struct P {
  long long n, d;
};
int main() {
  long long n, m;
  cin >> n >> m;
  vector<vector<P>> M(n);
  vector<long long> line(n, -1);
  for (int i = 0; i < m; ++i) {
    long long foo, fooo, hoge;
    cin >> foo >> fooo >> hoge;
    foo--;
    fooo--;
    P a, b;
    if (foo > fooo) swap(foo, fooo);
    a.n = fooo;
    a.d = hoge;
    b.n = foo;
    b.d = hoge;
    M[foo].emplace_back(a);
  }
  queue<long long> Q;
  for (int iii = 0; iii < n; ++iii) {
    if (line[iii] != -1) {
      continue;
    } else {
      Q.push(iii);
      line[iii] = 0;
    }
    while (!Q.empty()) {
      long long now = Q.front();
      Q.pop();
      for (long long i = 0; i < M[now].size(); ++i) {
        if (line[M[now][i].n] == -1) {
          line[M[now][i].n] = M[now][i].d - line[now];
          Q.push(M[now][i].n);
        } else {
          if (line[M[now][i].n] - line[now] != M[now][i].d) {
            cout << "No" << endl;
            return 0;
          }
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << "Yes" << endl;
    return 0;
    cout << line[i] << endl;
  }
  return 0;
}
