#include <bits/stdc++.h>
using namespace std;
const long long INF = LLONG_MAX - 100;
const long long mod = 1e9 + 7;
const long long MAX_N = 5e5 + 5;
long long dx[] = {-1LL, 0, 1LL, 0}, dy[] = {0, 1LL, 0, -1LL};
vector<long long> prime;
long long inv[MAX_N], fac[MAX_N];
template <class T = long long>
T in() {
  T x;
  cin >> x;
  return (x);
}
inline long long GCD(long long a, long long b) {
  long long c;
  while (b != 0) {
    c = a % b;
    a = b;
    b = c;
  }
  return a;
}
inline long long LCM(long long a, long long b) { return a * b / GCD(a, b); }
inline long long POW(long long a, long long b) {
  long long c = 1LL;
  while (b > 0) {
    if (b & 1LL) {
      c = a * c % mod;
    }
    a = a * a % mod;
    b >>= 1LL;
  }
  return c;
}
inline void _nCr() {
  fac[0] = 1LL;
  for (long long i = 1LL; i < MAX_N; i++) {
    fac[i] = fac[i - 1LL] * i % mod;
  }
  for (long long i = 0; i < MAX_N; i++) {
    inv[i] = POW(fac[i], mod - 2);
  }
}
inline long long nCr(long long n, long long r) {
  return (fac[n] * inv[r] % mod) * inv[n - r] % mod;
}
inline void PRI(long long n) {
  bool a[n + 1LL];
  for (long long i = 0; i < n + 1LL; i++) {
    a[i] = 1LL;
  }
  for (long long i = 2; i < n + 1LL; i++) {
    if (a[i]) {
      prime.push_back(i);
      long long b = i;
      while (b <= n) {
        a[b] = 0;
        b += i;
      }
    }
  }
}
class UnionFind {
 private:
  vector<long long> par;

 public:
  UnionFind(long long N) { par = vector<long long>(N, -1LL); }
  long long find(long long x);
  long long size(long long x);
  void unite(long long x, long long y);
  bool same(long long x, long long y);
};
class Kruskal {
 private:
  UnionFind *uf;
  vector<pair<long long, pair<long long, long long>>> e;

 public:
  vector<pair<long long, pair<long long, long long>>> mst;
  Kruskal(long long N) { uf = new UnionFind(N); }
  void add(long long x, long long y, long long z);
  void run();
};
long long UnionFind::find(long long x) {
  if (par[x] < 0)
    return x;
  else
    return par[x] = find(par[x]);
}
long long UnionFind::size(long long x) { return -par[find(x)]; }
void UnionFind::unite(long long x, long long y) {
  x = find(x);
  y = find(y);
  if (size(x) < size(y)) swap(x, y);
  par[x] += par[y];
  par[y] = x;
}
bool UnionFind::same(long long x, long long y) {
  x = find(x);
  y = find(y);
  return x == y;
}
void Kruskal::add(long long x, long long y, long long z) {
  if (x > y) swap(x, y);
  e.push_back({z, {x, y}});
}
void Kruskal::run() {
  sort(e.begin(), e.end());
  e.erase(unique(e.begin(), e.end()), e.end());
  for (auto x : e) {
    if (uf->same(x.second.first, x.second.second)) {
      continue;
    } else {
      mst.push_back(x);
      uf->unite(x.second.first, x.second.second);
    }
  }
}
long long dis[100005];
vector<vector<pair<long long, long long>>> ed(100005);
signed main() {
  long long n, m;
  cin >> n >> m;
  for (long long(i) = (0); (i) < (m); (i)++) {
    long long l, r, d;
    cin >> l >> r >> d;
    ed[l].push_back({r, d});
    ed[r].push_back({l, -d});
  }
  for (long long(i) = (0); (i) < (100005); (i)++) dis[i] = -1;
  for (long long(i) = (0); (i) < (n); (i)++) {
    if (dis[i] == -1) {
      dis[i] = 0;
      queue<long long> p;
      p.push(i);
      while (!p.empty()) {
        long long here = p.front();
        p.pop();
        for (long long(i) = (0); (i) < (ed[here].size()); (i)++) {
          if (dis[ed[here][i].first] == -1) {
            dis[ed[here][i].first] = dis[here] + ed[here][i].second;
            p.push(ed[here][i].first);
          } else if (dis[ed[here][i].first] != dis[here] + ed[here][i].second) {
            cout << "No" << endl;
            return 0;
          }
        }
      }
    }
  }
  cout << "Yes" << endl;
}
