#include <bits/stdc++.h>
using namespace std;
int n, m;
int v[200001];
pair<pair<int, int>, int> x[200001];
vector<int> ord;
bool check() {
  map<int, int> o;
  map<int, bool> is;
  is.clear();
  o[x[ord[0]].first.first] = 1;
  for (int i = 0; i < ord.size(); i++) {
    int a = x[ord[i]].first.first, b = x[ord[i]].first.second;
    if (is[a] && is[b]) {
      if (o[b] - x[ord[i]].second != o[a]) return 0;
    } else {
      if (!is[a]) {
        is[a] = 1;
        o[a] = o[b] - x[ord[i]].second;
      }
      if (!is[b]) {
        is[b] = 1;
        o[b] = o[a] + x[ord[i]].second;
      }
    }
  }
  return 1;
}
void dfs(int y, int co) {
  ord.push_back(y);
  for (int i = 0; i < m; i++) {
    if (v[i]) continue;
    if (x[y].first.first == x[i].first.first ||
        x[y].first.first == x[i].first.second ||
        x[y].first.second == x[i].first.first ||
        x[y].first.second == x[i].first.second) {
      v[i] = co;
      dfs(i, co);
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> x[i].first.first >> x[i].first.second >> x[i].second;
  }
  int cnt = 0;
  for (int i = 0; i < m; i++) {
    if (!v[i]) {
      cnt++;
      ord.clear();
      dfs(i, cnt);
      if (!check()) {
        cout << "No" << endl;
        exit(0);
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
