#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, m;
int fa[N], dis[N];
int find(int x) {
  if (x == fa[x]) return x;
  dis[x] += dis[fa[x]];
  fa[x] = find(fa[x]);
  return fa[x];
}
int main() {
  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, d;
    scanf("%d%d%d", &x, &y, &d);
    int fx = find(x), fy = find(y);
    if (fx == fy && (dis[y] - dis[x]) != d) {
      puts("No");
      return 0;
    }
    if (fx != fy) {
      fa[fy] = fx;
      dis[fy] = -dis[y] + dis[x] + d;
    }
  }
  puts("Yes");
  return 0;
}
