#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200000 + 9;
int fa[MAXN];
int val[MAXN];
int n, m;
map<int, int> ma[MAXN];
int Find(int x) {
  if (fa[x] == x) return x;
  int tmp = fa[x];
  int det = val[x] - val[fa[x]];
  fa[x] = Find(fa[x]);
  val[x] = val[tmp] + det;
  return fa[x];
}
void Union(int x, int y, int det) {
  int xx = Find(x);
  int yy = Find(y);
  val[y] = val[x] + det;
  fa[yy] = xx;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    fa[i] = i;
  }
  for (int i = 1; i <= m; i++) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    int aa = Find(a);
    int bb = Find(b);
    if (aa == bb) {
      if (c != val[b] - val[a]) {
        puts("No");
        return 0;
      }
    } else
      Union(a, b, c);
  }
  puts("Yes");
  return 0;
}
