#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, l, r, d;
  cin >> n >> m;
  bool flag = false;
  vector<pair<int, int>> que(n + 1, pair<int, int>(-1, 0));
  vector<int> dis(0);
  vector<int> numcheck(n, -1);
  for (int i = 0; i < m; i++) {
    cin >> l >> r >> d;
    if (!flag) {
      int check = l, d1 = 0;
      while (que[check].first != -1) {
        d1 += que[check].second;
        check = que[check].first;
      }
      int check2 = r, d2 = 0;
      while (que[check2].first != -1) {
        d2 += que[check2].second;
        check2 = que[check2].first;
      }
      if (check == check2) {
        if (d2 - d1 != d) {
          flag = true;
        }
      } else {
        que[r].first = l;
        que[r].second = d;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (que[i].first == -1) continue;
    if (!flag) {
      int temp = i, d3 = 0;
      while (que[temp].first != -1) {
        if (numcheck[temp] != -1) {
          d3 += numcheck[temp];
          break;
        }
        d3 += que[temp].second;
        temp = que[temp].first;
      }
      temp = dis.size();
      for (int j = 0; j < temp; j++) {
        if (dis[j] == d3) {
          flag = true;
          break;
        }
      }
      dis.push_back(d3);
    }
  }
  if (flag) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}
