#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 6;
pair<pair<int, int>, int> pp[N];
vector<pair<int, int> > vec[N];
vector<int> rev[N];
long long int dis[N], vis[N];
void dfs(int u) {
  vis[u] = true;
  for (int i = 0; i < vec[u].size(); i++) {
    int v = vec[u][i].first;
    int w = vec[u][i].second;
    if (!vis[v]) {
      dis[v] = dis[u] + w;
      dfs(v);
    } else {
      if (dis[v] != dis[u] + w) {
        cout << "No\n";
        exit(0);
      }
    }
  }
}
int main() {
  long long int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    pp[i] = make_pair(make_pair(l, r), d);
    vec[l].push_back(make_pair(r, d));
    rev[r].push_back(l);
  }
  for (int i = 1; i <= n; i++) {
    dfs(i);
  }
  cout << "Yes\n";
  return 0;
}
