#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int n, m, fa[MAXN], val[MAXN];
int find(int x) {
  if (fa[x] < 0) return x;
  int ret = find(fa[x]);
  val[x] += val[fa[x]];
  return fa[x] = ret;
}
int main() {
  int i, a, b, c;
  memset(fa, -1, sizeof(fa));
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; ++i) {
    scanf("%d%d%d", &a, &b, &c);
    if (find(a) != find(b)) {
      val[find(a)] = val[b] - c - val[a];
      fa[find(a)] = find(b);
    } else if (val[b] - val[a] != c) {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}
