#include <bits/stdc++.h>
using namespace std;
vector<pair<int, long long> > adj[200010];
long long dist[200100];
bool vis[200100];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int x, y, w;
    cin >> x >> y >> w;
    --x;
    --y;
    adj[x].push_back(make_pair(y, w));
  }
  bool flag = true;
  queue<int> q;
  for (int i = 0; i < n; ++i) {
    if (vis[i]) continue;
    q.push(i);
    dist[i] = 0;
    while (!q.empty()) {
      if (!flag) break;
      int u = q.front();
      q.pop();
      for (int i = 0; i < adj[u].size(); ++i) {
        int v = adj[u][i].first;
        if (!vis[v]) {
          q.push(v);
          dist[v] = dist[u] + adj[u][i].second;
          vis[v] = true;
        } else {
          if (dist[v] != dist[u] + adj[u][i].second) {
            flag = false;
            break;
          }
        }
      }
    }
  }
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
