#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 26;
int n, m;
int fa[100005], val[100005];
int gf(int x) {
  int i = x, r = x, j, sum = 0;
  while (r != fa[r]) {
    sum += val[r];
    r = fa[r];
  }
  int t = sum, tmp = val[i];
  val[i] = sum;
  while (i != r) {
    t -= tmp;
    j = fa[i];
    fa[i] = r;
    i = j;
    tmp = val[i];
    val[i] = t;
  }
  return r;
}
int main() {
  memset(val, 0, sizeof(val));
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) fa[i] = i;
  for (int i = 1; i <= m; i++) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    int fx = gf(x), fy = gf(y);
    if (fx != fy) {
      fa[fy] = fx;
      val[fy] = val[x] + z;
    } else {
      if (z != val[y] - val[x]) {
        puts("No");
        return 0;
      }
    }
  }
  puts("Yes");
  return 0;
}
