#include <bits/stdc++.h>
inline int getInt() {
  int s;
  scanf("%d", &s);
  return s;
}
using namespace std;
int n;
int m;
vector<pair<int, int> > v[100000];
int root[100000];
int dist[100000];
int rc[100000];
int main() {
  n = getInt();
  m = getInt();
  for (int i = 0; i < (int)(m); i++) {
    const int l = getInt() - 1;
    const int r = getInt() - 1;
    const int d = getInt();
    v[l].push_back(make_pair(r, d));
    rc[r]++;
  }
  for (int i = 0; i < (int)(n); i++) root[i] = -1;
  for (int i = 0; i < (int)(n); i++)
    if (rc[i] <= 1) {
      queue<int> q;
      q.push(i);
      root[i] = i;
      dist[i] = 0;
      while (q.size()) {
        const int pos = q.front();
        q.pop();
        for (const auto e : v[pos]) {
          const int next = e.first;
          const int d = e.second;
          if (root[next] == -1) {
            dist[next] = dist[pos] + d;
            root[next] = i;
            q.push(next);
          } else if (root[next] == i) {
            if (dist[next] != dist[pos] + d) {
              goto bad;
            }
          }
        }
      }
    }
  for (int i = 0; i < (int)(n); i++)
    if (root[i] == -1) {
      goto bad;
    }
  puts("Yes");
  return 0;
bad:
  puts("No");
  return 0;
}
