#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > edge[100100];
int in_deg[100100];
int po[100100];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i <= n; i++) po[i] = -1;
  for (int i = 0; i < m; i++) {
    int l, r, d;
    scanf("%d %d %d", &l, &r, &d);
    edge[l].push_back(make_pair(r, d));
    in_deg[r]++;
  }
  int err = 0;
  for (int i = 1; i <= n; i++) {
    if (in_deg[i] == 0) {
      po[i] = 0;
      queue<int> q;
      q.push(i);
      while (!q.empty()) {
        int nw = q.front();
        q.pop();
        for (int i = 0; i < edge[nw].size(); i++) {
          int go = edge[nw][i].first;
          int where = edge[nw][i].second + po[nw];
          if (po[go] != 0) {
            if (where != go) {
              err = 1;
            }
          } else {
            po[go] = where;
            if (where > 1e9) err = 1;
            q.push(go);
          }
        }
      }
    }
  }
  for (int i = 1; i <= n; i++)
    if (po[i] == -1) err = 1;
  printf("%s", (err == 0) ? "Yes" : "No");
}
