#include <bits/stdc++.h>
using namespace std;
using namespace std;
vector<vector<long long> > ta_min(0);
vector<vector<long long> > ta_max(0);
long long leth = 1024 * 512;
long long p = 1000000007;
vector<long long> par;
vector<long long> siz;
vector<long long> dis;
long long n;
void mmax(long long &a, long long b) { a = max(a, b); }
void mmin(long long &a, long long b) { a = min(a, b); }
pair<long long, long long> root(long long ser) {
  if (par[ser] == -1) {
    return make_pair(ser, 0);
  }
  pair<long long, long long> x = root(par[ser]);
  x.second += dis[ser];
  return x;
}
void uni(long long x, long long y, long long d) {
  pair<long long, long long> p1 = root(x);
  pair<long long, long long> p2 = root(y);
  long long x1 = p1.first;
  long long y1 = p2.first;
  if (siz[x1] < siz[y1]) {
    swap(x1, y1);
    swap(p1, p2);
    swap(x, y);
    d *= -1;
  }
  if (x1 != y1) {
    par[y1] = x1;
    dis[y1] = d + p1.second - p2.second;
  }
}
bool issame(long long x, long long y) { return root(x).first == root(y).first; }
void ref(long long &x) {
  x = x % p;
  x = (x + p) % p;
}
signed main() {
  cin >> n;
  long long m;
  cin >> m;
  par = vector<long long>(n, -1);
  siz = vector<long long>(n, 1);
  dis = vector<long long>(n, 0);
  for (long long i = 0; i < m; i++) {
    long long l, r;
    cin >> l >> r;
    l--;
    r--;
    long long d;
    cin >> d;
    if (!issame(l, r)) {
      uni(l, r, -d);
    } else {
      pair<long long, long long> l1 = root(l);
      pair<long long, long long> r1 = root(r);
      if (r1.second + d == l1.second) {
        uni(l1.first, r1.first, -d);
      } else {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
