#include <bits/stdc++.h>
using namespace std;
int par[100000];
int d[100000];
int n, m;
void init(int n) {
  int i;
  for (i = 1; i <= n; i++) {
    par[i] = i;
  }
}
int find(int x) {
  if (par[x] == x) return x;
  d[x] = d[par[x]] + d[x];
  return par[x] = find(par[x]);
}
int unite(int x, int y, int z) {
  int a = find(x);
  int b = find(y);
  if (a == b) return z = d[y] - d[x];
  par[b] = a;
  d[b] = d[x] + z - d[y];
  return 1;
}
int main() {
  int x, y, z;
  int f = 1;
  scanf("%d%d", &n, &m);
  init(n);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &x, &y, &z);
    if (f) f = unite(x, y, z);
  }
  if (f == 1)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}
