#include <bits/stdc++.h>
using namespace std;
int father[100500];
int dis[100500];
int seek(int x) {
  if (father[x] == x) return x;
  int a1 = father[x];
  int a2 = seek(father[x]);
  father[x] = a2;
  dis[x] = dis[x] + dis[a1];
  return a2;
}
int main(void) {
  int num, cas, L, R, D;
  cin >> num >> cas;
  for (int i = 0; i <= num; i++) {
    father[i] = i;
    dis[i] = 0;
  }
  while (cas--) {
    cin >> L >> R >> D;
    int fl = seek(L);
    int fr = seek(R);
    if (fl == fr) {
      if (dis[L] + D != dis[R]) {
        puts("No");
        return 0;
      }
    } else {
      father[R] = L;
      dis[R] = D;
    }
  }
  puts("Yes");
  return 0;
}
