#include <bits/stdc++.h>
using namespace std;
const int maxN = static_cast<const int>(1e5 + 10);
int fa[maxN], dis[maxN], N, M;
int find(int x) {
  if (x == fa[x]) {
    return x;
  }
  dis[x] += dis[fa[x]];
  fa[x] = find(fa[x]);
  return fa[x];
}
bool merge(int x, int y, int d) {
  int fx = find(x);
  int fy = find(y);
  if (fx == fy) {
    return dis[y] - dis[x] == d;
  } else {
    fa[fx] = fy;
    dis[fx] = dis[y] - dis[x] - d;
    return true;
  }
}
int main() {
  scanf("%d %d", &N, &M);
  memset(dis, 0, sizeof(dis));
  for (int i = 0; i <= N; ++i) {
    fa[i] = i;
  }
  int l, r, d;
  bool flag = true;
  for (int i = 0; i < M; ++i) {
    scanf("%d %d %d", &l, &r, &d);
    if (flag && !merge(l, r, d)) {
      flag = false;
    }
  }
  printf("%s\n", flag ? "Yes" : "No");
  return 0;
}
