#include <bits/stdc++.h>
using namespace std;
int n, m;
int x[200005];
int l[200005];
int r[200005];
int d[200005];
vector<int> v;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  memset(x, -1, sizeof(x));
  cin >> n >> m;
  int a, b;
  for (int i = 1; i <= m; i++) {
    cin >> a >> b;
    l[i] = min(a, b);
    r[i] = max(a, b);
    cin >> d[i];
    v.push_back(i);
    if (i == 1) x[l[i]] = 0, x[r[i]] = d[i];
  }
  while (v.size() > 0) {
    vector<int> u;
    for (int i = 0; i < v.size(); i++) {
      cout << "FA♂Q" << endl;
      bool f = 1;
      if (x[l[v[i]]] != -1) {
        if (x[r[v[i]]] == -1) {
          x[r[v[i]]] = x[l[v[i]]] + d[v[i]];
        }
        if (x[r[v[i]]] != x[l[v[i]]] + d[v[i]]) {
          cout << "No" << endl;
          return 0;
        }
        f = 0;
      }
      if (x[r[v[i]]] != -1) {
        if (x[l[v[i]]] == -1) {
          x[l[v[i]]] = x[r[v[i]]] - d[v[i]];
        }
        if (x[l[v[i]]] != x[r[v[i]]] - d[v[i]]) {
          cout << "No" << endl;
          return 0;
        }
        f = 0;
      }
      if (f) u.push_back(v[i]);
    }
    v = u;
  }
  cout << "Yes";
  return 0;
}
