#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000000000000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
                         {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};
struct UF {
  int par[100010], r[100010];
  void init() {
    for (int i = 0; i < 100010; i++) {
      par[i] = i;
      r[i] = 0;
    }
  }
  int find(int x) {
    if (par[x] == x) return x;
    return par[x] = find(par[x]);
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int unit(int x, int y) {
    if (same(x, y)) return -1;
    x = find(x);
    y = find(y);
    if (r[x] < r[y]) {
      par[x] = y;
      return x;
    } else {
      par[y] = x;
      if (r[x] == r[y]) {
        r[x]++;
      }
      return y;
    }
  }
} uf;
int main() {
  static long long n, m;
  static long long l[200010], r[100010], d[100010];
  scanf("%lld%lld", &n, &m);
  for (int i = 0; i < m; i++) scanf("%lld%lld%lld", &l[i], &r[i], &d[i]);
  static long long x[200010] = {};
  uf.init();
  for (int i = 0; i < m; i++) {
    if (uf.same(l[i], r[i])) {
      int a = x[uf.find(l[i])] + x[l[i]];
      int b = x[uf.find(r[i])] + x[r[i]];
      if (a + d[i] != b) {
        puts("No");
        return 0;
      }
    } else {
      int L = uf.find(l[i]);
      int R = uf.find(r[i]);
      int a = x[L] + x[l[i]];
      int b = x[R] + x[r[i]];
      int c = b - (a + d[i]);
      int X = uf.unit(l[i], r[i]);
      if (X == L) {
        x[L] += c;
      } else {
        x[R] -= c;
      }
    }
  }
  puts("Yes");
}
