#include <bits/stdc++.h>
using namespace std;
int w, n, m;
int s, t, v;
int f[100005], val[100005];
bool flag = 0;
int find(int x) {
  if (f[x] == x) return x;
  int F = find(f[x]);
  val[x] += val[f[x]];
  return f[x] = F;
}
void Union(int x, int y, int w) {
  int a = find(x), b = find(y);
  if (a != b)
    f[a] = b, val[a] = val[y] - val[x] - w;
  else if (val[y] - val[x] != w)
    flag = 1;
}
int main() {
  scanf("%d%d", &n, &m);
  flag = 0;
  for (int i = 0; i <= n; i++) f[i] = i, val[i] = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &s, &t, &v);
    if (s > t) swap(t, s);
    Union(s, t, v);
  }
  printf(flag ? "No\n" : "Yes\n");
  return 0;
}
