#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v[100010];
int n, m;
int l[100010];
int r[100010];
int d[100010];
int bio[100010];
int yes[100010];
int dist[100010];
int da = 1;
void dfs(int x) {
  yes[x] = 1;
  for (int i = 0; i < v[x].size(); i++) {
    if (da == 0) {
      return;
    }
    int sus = v[x][i].first;
    int cost = v[x][i].second;
    if (dist[sus] != -1 && dist[sus] - dist[x] != cost) {
      da = 0;
      return;
    }
    if (yes[sus] == 0) {
      dist[sus] = dist[x] + cost;
      dfs(sus);
    }
  }
}
int main() {
  cin >> n >> m;
  memset(dist, -1, sizeof dist);
  for (int i = 0; i < m; i++) {
    cin >> l[i] >> r[i] >> d[i];
    v[l[i]].push_back(make_pair(r[i], d[i]));
    v[r[i]].push_back(make_pair(l[i], -d[i]));
    bio[r[i]] = 1;
  }
  int j = 0;
  for (int i = 1; i <= m; i++) {
    if (bio[i] == 0 && yes[i] == 0) {
      dist[i] = 0;
      dfs(i);
      j = 1;
    }
  }
  if (m == 0) {
    cout << "Yes";
  } else if (j == 0 || da == 0) {
    cout << "No";
  } else {
    cout << "Yes";
  }
  return 0;
}
