#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to, cost;
};
vector<edge> edges[100010];
void markAllReachable(int n) {}
int n, m;
long long dist[100010];
void walk(int start, bool mode) {
  for (auto hoge : edges[start]) {
    if (mode) {
      if (hoge.cost >= 0) {
        dist[hoge.to] = dist[start] + hoge.cost;
        walk(hoge.to, mode);
      }
    } else {
      if (hoge.cost <= 0) {
        dist[hoge.to] = dist[start] + hoge.cost;
        walk(hoge.to, mode);
      }
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    edge tmp = {r, d};
    edges[l].push_back(tmp);
    tmp = {l, -d};
    edges[r].push_back(tmp);
  }
  for (int i = 0; i < n; i++) {
    bool f = true;
    for (auto hoge : edges[i]) {
      if (hoge.cost < 0) {
        f = false;
        break;
      }
    }
    if (f) {
      walk(i, true);
    }
  }
  for (int i = 0; i < n; i++) {
    bool f = true;
    for (auto hoge : edges[i]) {
      if (hoge.cost > 0) {
        f = false;
        break;
      }
    }
    if (f) {
      walk(i, false);
    }
  }
  for (int i = 0; i < n; i++) {
    for (auto hoge : edges[i]) {
      if (dist[i] + hoge.cost != dist[hoge.to]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}
