#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main() {
  int N, M;
  int L[200000], R[200000], D[200000];
  cin >> N >> M;
  for (int i = 0; i < M; i++) cin >> L[i] >> R[i] >> D[i];
  vector<pair<int, int>> vec[100000];
  for (int i = 0; i < M; i++) {
    vec[L[i]].push_back(make_pair(R[i], D[i]));
    vec[R[i]].push_back(make_pair(L[i], -1 * D[i]));
  }
  bool done[100000];
  int pos[100000];
  queue<int> que;
  int now, next;
  for (int i = 0; i < N; i++) {
    if (done[i]) continue;
    pos[i] = 0;
    done[i] = true;
    que.push(i);
    while (!que.empty()) {
      now = que.front();
      que.pop();
      while (!vec[now].empty()) {
        next = vec[now].back().first;
        if (done[next]) {
          vec[now].pop_back();
          continue;
        }
        done[next] = true;
        pos[next] = pos[now] + vec[now].back().second;
        que.push(next);
        vec[now].pop_back();
      }
    }
  }
  for (int i = 0; i < M; i++) {
    if ((pos[R[i]] - pos[L[i]]) != D[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
