#include <bits/stdc++.h>
using namespace std;
int x, y, z, mi[200001], ma[200001];
int n, m, fa[200001], dis[200001];
void add(int x, int y, int z) {
  fa[x] = y;
  dis[x] = z;
}
int getfa(int x) {
  if (fa[x] == x)
    return x;
  else {
    int tem = getfa(fa[x]);
    dis[x] += dis[fa[x]];
    return fa[x] = tem;
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) fa[i] = i;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &x, &y, &z);
    if (getfa(x) != getfa(y)) {
      add(getfa(x), getfa(y), dis[x] - dis[y] + z);
    } else {
      if (dis[x] - dis[y] != z) {
        puts("No");
        exit(0);
      }
    }
  }
  for (int i = 1; i <= n; i++)
    mi[getfa(i)] = min(mi[getfa(i)], dis[i]),
    ma[getfa(i)] = max(ma[getfa(i)], dis[i]);
  for (int i = 1; i <= n; i++)
    if (ma[i] - mi[i] > 1000000000) {
      puts("No");
      exit(0);
    }
  puts("Yes");
  return 0;
}
