#include <bits/stdc++.h>
using namespace std;
;
const int MOD = 1e9 + 7;
const int INF = 2e9;
const int MAX_N = 100000;
const int MAX_M = 200000;
int N, M, L, R, D;
int pos[MAX_N];
bool used[MAX_N];
vector<vector<pair<int, int> > > dist(MAX_N);
bool dfs(int x) {
  if (used[x]) return true;
  used[x] = true;
  for (vector<pair<int, int> >::iterator it = dist[x].begin();
       it != dist[x].end(); ++it) {
    if (pos[it->first] == INF) {
      pos[it->first] = pos[x] + it->second;
      dfs(it->first);
    } else {
      if (pos[it->first] != pos[x] + it->second) {
        return false;
      }
    }
  }
  used[x] = false;
  return true;
}
int main() {
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    pos[i] = INF;
    used[i] = false;
  }
  for (int i = 0; i < M; i++) {
    cin >> L >> R >> D;
    L--;
    R--;
    dist[L].push_back(make_pair(R, D));
    dist[R].push_back(make_pair(L, -D));
  }
  for (int i = 0; i < N; i++) {
    if (pos[i] == INF) pos[i] = 0;
    if (!dfs(i)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
