#include <bits/stdc++.h>
const bool DEBUG = false;
using namespace std;
const long long maxn = 2e5 + 5;
const long long INF = 4e18;
const long long M = 1e9 + 7;
const int lg = 21;
int n, m, x[maxn];
vector<pair<int, int> > r[maxn], l[maxn];
bool mark[maxn], flag;
void dfs(int v) {
  if (flag) return;
  mark[v] = 1;
  for (auto u : r[v]) {
    int L = v, R = u.first, d = u.second;
    int z = x[L] + d;
    if (x[R] != -1) {
      if (x[R] != z) flag = 1;
    } else {
      x[R] = z;
      dfs(R);
    }
  }
  for (auto u : l[v]) {
    int L = u.first, R = v, d = u.second;
    int z = x[R] - d;
    if (x[L] != -1) {
      if (x[L] != z) flag = 1;
    } else {
      x[L] = z;
      dfs(L);
    }
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  fill(x, x + maxn, -1);
  for (int i = 0; i < m; i++) {
    int L, R, d;
    cin >> L >> R >> d, L--, R--;
    r[L].push_back({R, d});
    l[R].push_back({L, d});
  }
  for (int i = 0; i < n; i++) {
    if (mark[i]) continue;
    x[i] = 0;
    dfs(i);
  }
  if (flag)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}
