#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N, M;
int p[100001];
int s[100001];
int d[100001];
void make_set(int i) {
  p[i] = i;
  s[i] = 1;
  d[i] = 0;
}
int distance(int i) {
  int D = 0;
  while (p[i] != i) {
    D += d[i];
    i = p[i];
  }
  return D;
}
int find(int i) {
  while (p[i] != i) {
    i = p[i];
  }
  return i;
}
void union_tree(int L, int R, int D) {
  int q1 = find(R);
  int q2 = find(L);
  if (s[q1] >= s[q2]) {
    p[q2] = q1;
    s[q1]++;
    d[q2] = D;
  } else {
    p[q1] = q2;
    s[q2]++;
    d[q1] = -D;
  }
}
int main() {
  cin >> N >> M;
  for (int i = 1; i < N + 1; ++i) {
    make_set(i);
  }
  for (int i = 0; i < M; ++i) {
    int L, R, D;
    cin >> L >> R >> D;
    if (find(L) == find(R)) {
      if (distance(L) - distance(R) != D) {
        cout << "No" << endl;
        return 0;
      }
    } else {
      union_tree(L, R, D);
    }
  }
  cout << "Yes" << endl;
  return 0;
}
