#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = (1 << 30);
const long long INFL = INF * INF;
long long N, M;
bool ans = true;
vector<map<long long, long long>> edge;
void input() {
  cin >> N >> M;
  edge.resize(N);
  long long l, r, d;
  for (int((i)) = (0); ((i)) < ((M)); ((i))++) {
    cin >> l >> r >> d;
    l--;
    r--;
    edge[l][r] = d;
    edge[r][l] = -d;
  }
}
template <typename T>
void show(vector<T> v) {
  for (auto col : v) cout << col << " ";
  cout << endl;
}
template <typename T>
void show(vector<vector<T>> v) {
  for (auto row : v) show(row);
  cout << endl;
}
void calc() {
  vector<bool> went(N, false);
  vector<long long> place(N, INFL);
  queue<pair<long long, long long>> q;
  int cnt = 0;
  for (int((i)) = (0); ((i)) < ((N)); ((i))++) {
    if (went[i]) continue;
    if (edge[i].size() == 0) continue;
    cnt++;
    place[i] = INF * cnt;
    went[i] = true;
    for (auto itr = edge[i].begin(); itr != edge[i].end(); ++itr) {
      q.push(make_pair(i, itr->first));
    }
    while (!q.empty()) {
      auto now = q.front();
      q.pop();
      went[now.first] = true;
      long long will = place[now.first] + edge[now.first][now.second];
      edge[now.first].erase(now.second);
      edge[now.second].erase(now.first);
      if (place[now.second] != INF) {
        if (place[now.second] != will) {
          ans = false;
          break;
        }
      } else {
        place[now.second] = will;
        for (auto itr = edge[now.second].begin(); itr != edge[now.second].end();
             ++itr) {
          q.push(make_pair(now.second, itr->first));
        }
      }
    }
  }
}
void output() { cout << (ans ? "Yes" : "No") << endl; }
void debug() {
  int N;
  cin >> N;
}
int main() {
  input();
  calc();
  output();
  return 0;
}
