#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int pre[maxn];
int dis[maxn];
int findset(int x) {
  if (x == pre[x]) return x;
  pre[x] = findset(pre[x]);
  dis[x] = dis[pre[x]] + dis[x];
  return pre[x];
}
bool unionset(int x, int y, int w) {
  int fx = findset(x), fy = findset(y);
  if (fx == fy) return w == dis[y] - dis[x];
  pre[fy] = fx;
  dis[fy] = dis[x] + w - dis[y];
  return true;
}
int n, m;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) pre[i] = i;
  bool lose = true;
  for (int i = 0; i < m; i++) {
    int x, y, w;
    scanf("%d%d%d", &x, &y, &w);
    if (lose) lose = unionset(x, y, w);
  }
  if (lose)
    printf("Yes\n");
  else
    printf("No\n");
}
