#include <bits/stdc++.h>
using namespace std;
int N, M;
int L[200000], R[200000], D[200000];
vector<pair<int, int> > el[100000], er[100000];
long long X[100000];
bool dfs(int id, long long a) {
  if (X[id] == -1) {
    X[id] = a;
    for (int i = 0; i < el[id].size(); i++) {
      if (!dfs(el[id][i].first, a - el[id][i].second)) return 0;
    }
    for (int i = 0; i < er[id].size(); i++) {
      if (!dfs(er[id][i].first, a + er[id][i].second)) return 0;
    }
    return 1;
  } else {
    if (X[id] != a) return 0;
    if (X[id] == a) return 1;
  }
}
int main() {
  cin >> N >> M;
  memset(X, -1, sizeof(X));
  for (int i = 0; i < M; i++) {
    cin >> L[i] >> R[i] >> D[i];
    el[R[i]].push_back(pair<int, int>(L[i], D[i]));
    er[L[i]].push_back(pair<int, int>(R[i], D[i]));
  }
  for (int i = 0; i < N; i++) {
    if (X[i] == -1 && !dfs(i, 1e+10)) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
}
