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