#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e15;
struct node {
  int l;
  int r;
  int dis;
} mp[200010];
bool cmp(node x, node y) {
  if (x.l == y.l)
    return x.r < y.r;
  else
    return x.l < y.l;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    scanf("%d %d %d", &mp[i].l, &mp[i].r, &mp[i].dis);
    if (mp[i].l > mp[i].r) {
      swap(mp[i].l, mp[i].r);
      mp[i].dis = -mp[i].dis;
    }
  }
  bool flag = 1;
  sort(mp + 1, mp + m + 1, cmp);
  long long d[100020];
  for (int i = 1; i <= 100010; i++) d[i] = INF;
  d[mp[1].l] = 0;
  for (int i = 1; i <= m; i++) {
    if (d[mp[i].l] != INF) {
      if (d[mp[i].r] == INF) {
        d[mp[i].r] = d[mp[i].l] + mp[i].dis;
      } else if (d[mp[i].r] != INF) {
        if (d[mp[i].r] != d[mp[i].l] + mp[i].dis) flag = 0;
      }
    }
  }
  if (flag == 1)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
