#include <bits/stdc++.h>
using namespace std;
int fa[100000], off[100000];
int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) fa[i] = i;
  for (int i = 0; i < m; ++i) {
    int l, r, d;
    scanf("%d%d%d", &l, &r, &d);
    int fl = find(l), fr = find(r);
    if (fl == fr) {
      if (off[r] - off[l] == d)
        continue;
      else {
        puts("No");
        return 0;
      }
    } else {
      fa[fr] = fl;
      off[fr] = d - off[r] + off[l];
    }
  }
  puts("Yes");
  return 0;
}
