#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
long long mod = 998244353;
int inf = 1000001000;
long long INF = 10000000000000000;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n + 1, -1), c(n + 1);
  vector<vector<int>> b(n + 1, vector<int>(0));
  int t = 0;
  for (int(i) = 0; (i) < (m); (i)++) {
    int f, g, h;
    cin >> f >> g >> h;
    if (a[f] == -1 && a[g] == -1) {
      a[f] = t;
      a[g] = t;
      b[t].push_back(f);
      b[t].push_back(g);
      t++;
      c[f] = 0;
      c[g] = h;
    } else if (a[f] == -1 && a[g] != -1) {
      a[f] = a[g];
      b[a[g]].push_back(f);
      c[f] = c[g] - h;
    } else if (a[f] != -1 && a[g] == -1) {
      a[g] = a[f];
      b[a[f]].push_back(g);
      c[g] = c[f] + h;
    } else if (a[f] != a[g]) {
      int k = c[f] + h - c[g];
      for (int(j) = 0; (j) < (b[a[g]].size()); (j)++) {
        int u = b[a[g]][j];
        b[a[f]].push_back(u);
        a[u] = a[f];
        c[u] += k;
      }
    } else if (a[f] == a[g]) {
      if (c[f] + h != c[g]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}
