#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int l[m], r[m], d[m];
  vector<pair<int, int> > edge[n];
  for (int i = 0; i < m; i++) {
    cin >> l[i] >> r[i] >> d[i];
    l[i]--;
    r[i]--;
    edge[l[i]].push_back(pair<int, int>(r[i], d[i]));
    edge[r[i]].push_back(pair<int, int>(l[i], -d[i]));
  }
  int num[n];
  fill(num, num + n, -1);
  for (int i = 0; i < n; i++) {
    if (num[i] != -1) continue;
    queue<int> que;
    num[i] = 0;
    que.push(i);
    int now;
    bool flg[n];
    fill(flg, flg + n, false);
    while (!que.empty()) {
      now = que.front();
      que.pop();
      if (flg[now])
        continue;
      else
        flg[now] = true;
      for (int j = 0; j < edge[now].size(); j++) {
        num[edge[now][j].first] = num[now] + edge[now][j].second;
        que.push(edge[now][j].first);
      }
    }
  }
  bool check = true;
  for (int i = 0; i < m; i++) {
    if (num[r[i]] - num[l[i]] != d[i]) {
      check = false;
      break;
    }
  }
  cout << (check ? "Yes" : "No") << endl;
  return 0;
}
