#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e11;
const int MOD = 1e9 + 7;
long long int mi, ma;
long long int f = 1;
void dfs(int v, vector<long long int> &g,
         vector<vector<pair<int, int> > > &path) {
  for (__typeof((path[v]).begin()) e = (path[v]).begin(); e != (path[v]).end();
       ++e) {
    int right = (*e).first, d = (*e).second;
    if (g[right] == INF) {
      g[right] = g[v] + d;
      mi = min(mi, g[right]);
      ma = max(ma, g[right]);
      dfs(right, g, path);
    } else {
      if (g[right] - g[v] != d) f = 0;
    }
  }
}
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<long long int> g(n + 1, INF);
  vector<vector<pair<int, int> > > path(n);
  for (int i = 0; i < (int)(m); i++) {
    int l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    if (l > r) {
      path[r].push_back(pair<int, int>(l, -d));
    } else {
      path[l].push_back(pair<int, int>(r, d));
    }
  }
  for (int i = 0; i < (int)(n); i++) {
    mi = 0LL, ma = 0LL;
    if (g[i] == INF) g[i] = 0L;
    dfs(i, g, path);
    if (ma - mi > 1e9) f = 0;
  }
  cout << (f ? "Yes" : "No") << endl;
  return 0;
}
