#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e11;
int par[100000];
long long int diff_weight[100000];
int height[100000];
void init(int n) {
  for (int i = 0; i < n; i++) {
    par[i] = i;
    height[i] = 0;
    diff_weight[i] = 0;
  }
}
int find(int x) {
  if (par[x] == x) {
    return x;
  } else {
    diff_weight[x] += diff_weight[par[x]];
    return par[x] = find(par[x]);
  }
}
long long int weight(int x) {
  find(x);
  return diff_weight[x];
}
bool unite(int x, int y, long long int w) {
  w += weight(x);
  w -= weight(y);
  x = find(x);
  y = find(y);
  if (x == y) return false;
  if (height[x] < height[y]) {
    swap(x, y);
    w = -w;
  }
  if (height[x] == height[y]) {
    height[x]++;
  }
  par[y] = x;
  diff_weight[y] = w;
  return true;
}
bool same(int x, int y) { return find(x) == find(y); }
long long int diff(int x, int y) { return weight(y) - weight(x); }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  if (M == 0)
    cout << "Yes"
         << "\n";
  else {
    init(N);
    for (int i = int(0); i < int(M); i++) {
      int l, r, d;
      cin >> l >> r >> d;
      l--;
      r--;
      if (same(l, r)) {
        if (diff(l, r) != d) {
          cout << "No"
               << "\n";
          return 0;
        }
      } else {
        unite(l, r, d);
      }
    }
    cout << "Yes"
         << "\n";
  }
}
