#include <bits/stdc++.h>
using namespace std;
struct node {
  int f, dis;
};
node f[100001];
int findx(int x) {
  if (f[x].f == x) return x;
  int k = findx(f[x].f);
  f[x].dis = f[f[x].f].dis + f[x].dis;
  f[x].f = k;
  return k;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    f[i].f = i;
    f[i].dis = 0;
  }
  for (int i = 1; i <= m; i++) {
    int a, b, d;
    cin >> a >> b >> d;
    if (findx(a) != findx(b)) {
      f[b].f = a;
      f[b].dis = d;
    } else {
      if (f[b].dis - f[a].dis != d) {
        cout << "No";
        return 0;
      }
    }
  }
  cout << "Yes";
}
