#include <bits/stdc++.h>
using namespace std;
vector<pair<pair<int, int>, int> > zohe;
int ehoz[100000];
bool exe[100000];
int main(void) {
  int n, m;
  bool flag = true;
  cin >> n >> m;
  zohe.resize(m);
  for (int i = 0; i < m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    if (l > r) {
      zohe[i].first.first = r - 1;
      zohe[i].first.second = l - 1;
      zohe[i].second = -d;
    }
    if (l < r) {
      zohe[i].first.first = l - 1;
      zohe[i].first.second = r - 1;
      zohe[i].second = d;
    }
  }
  for (int i = 0; i < n; i++) ehoz[i] = -1;
  sort(zohe.begin(), zohe.end());
  for (int i = 0; i < m; i++) {
    if (!exe[zohe[i].first.first] && !exe[zohe[i].first.second]) {
      ehoz[zohe[i].first.first] = 0;
      ehoz[zohe[i].first.second] = zohe[i].second;
      exe[zohe[i].first.first] = true;
      exe[zohe[i].first.second] = true;
    }
    if (!exe[zohe[i].first.first] && exe[zohe[i].first.second]) {
      ehoz[zohe[i].first.first] = ehoz[zohe[i].first.second] - zohe[i].second;
      exe[zohe[i].first.first] = true;
    }
    if (exe[zohe[i].first.first] && !exe[zohe[i].first.second]) {
      ehoz[zohe[i].first.second] = ehoz[zohe[i].first.first] + zohe[i].second;
      exe[zohe[i].first.second] = true;
    }
    if (exe[zohe[i].first.first] && exe[zohe[i].first.second]) {
      if (ehoz[zohe[i].first.second] - ehoz[zohe[i].first.first] !=
          zohe[i].second) {
        flag = false;
        break;
      }
    }
  }
  cout << (flag ? "Yes" : "No") << endl;
}
