#include <bits/stdc++.h>
using namespace std;
class UF {
 public:
  int o[100100];
  int u[100100];
  UF(int n) {
    for (int i = 0; i < n; i++) {
      o[i] = -1;
      u[i] = i;
    }
  }
  int root(int s) {
    while (o[s] >= 0) s = o[s];
    return u[s];
  }
  void merge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    o[x] += o[y];
    o[y] = x;
  }
  bool same(int x, int y) { return root(x) == root(y); }
};
int main() {
  int n, m;
  cin >> n >> m;
  UF uni(n + 10);
  bool flag = true;
  int human[n + 10];
  for (int i = 0; i < n + 10; i++) human[i] = -2147483647;
  for (int i = 0; i < m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    if (uni.same(l, r)) {
      if (human[r] - human[l] != d) flag = false;
    } else {
      if (uni.o[r] == -1 && uni.o[l] == -1) {
        human[r] = d;
        human[l] = 0;
        uni.merge(r, l);
      } else if (uni.o[r] == -1) {
        human[r] = human[l] + d;
        uni.merge(l, r);
      } else if (uni.o[l] == -1) {
        human[l] = human[r] - d;
        uni.merge(r, l);
      } else {
        int num = human[uni.root(r)] - human[uni.root(l)];
        for (int i = 1; i <= n; i++) {
          if (uni.same(l, i)) human[i] -= num;
        }
        uni.merge(r, l);
      }
    }
  }
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
