#include <bits/stdc++.h>
using namespace std;
template <class A>
void pr(A a) {
  cout << a;
  cout << '\n';
}
template <class A, class B>
void pr(A a, B b) {
  cout << a << ' ';
  pr(b);
}
template <class A, class B, class C>
void pr(A a, B b, C c) {
  cout << a << ' ';
  pr(b, c);
}
template <class A, class B, class C, class D>
void pr(A a, B b, C c, D d) {
  cout << a << ' ';
  pr(b, c, d);
}
template <class A>
void PR(A a, long long n) {
  for (long long i = (long long)(0); i < (long long)(n); i++) {
    if (i) cout << ' ';
    cout << a[i];
  }
  cout << '\n';
}
long long check(long long n, long long m, long long x, long long y) {
  return x >= 0 && x < n && y >= 0 && y < m;
}
const long long MAX = 1e9 + 7, MAXL = 1LL << 61, dx[4] = {-1, 0, 1, 0},
                dy[4] = {0, 1, 0, -1};
void Main() {
  long long n, m;
  cin >> n >> m;
  long long e[n];
  memset(e, 0, sizeof(e));
  vector<pair<long long, long long> > v[n];
  for (long long i = (long long)(0); i < (long long)(m); i++) {
    long long x, y, z;
    cin >> x >> y >> z;
    x--, y--;
    if (x > y) {
      swap(x, y);
      z *= -1;
    }
    v[y].push_back(pair<long long, long long>(x, z));
    e[x]++;
  }
  long long d[n];
  fill(d, d + n, MAXL);
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >,
                 greater<pair<long long, long long> > >
      que;
  for (long long i = (long long)(0); i < (long long)(n); i++) {
    if (!e[i]) {
      que.push(pair<long long, long long>(0, i));
      d[i] = 0;
    }
  }
  while (!que.empty()) {
    pair<long long, long long> p = que.top();
    que.pop();
    long long x = p.second, c = p.first;
    if (d[x] < c) continue;
    for (long long i = (long long)(0); i < (long long)(v[x].size()); i++) {
      long long y = v[x][i].first, cc = v[x][i].second;
      e[y]--;
      if (d[y] == MAXL || d[y] == c + cc) {
        d[y] = c + cc;
        if (!e[y]) que.push(pair<long long, long long>(c + cc, y));
      } else {
        pr("No");
        return;
      }
    }
  }
  pr("Yes");
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  Main();
  return 0;
}
