#include <bits/stdc++.h>
using namespace std;
const signed INF = (1LL << 30);
const long long MOD = (1e9 + 7);
const long long LINF = (1LL << 60);
const long long LMAX = LLONG_MAX;
void YN(bool b) { cout << (b ? "Yes" : "No") << endl; }
template <class tuple>
inline tuple gcd(tuple a, tuple b) {
  if (b == 0) return a;
  return (gcd(b, a % b));
}
template <class tuple>
inline tuple lcm(tuple a, tuple b) {
  return a / gcd(a, b) * b;
}
template <class tuple>
inline bool chmax(tuple &a, const tuple &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class tuple>
inline bool chmin(tuple &a, const tuple &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  long long n, m;
  cin >> n >> m;
  vector<vector<pair<long long, long long>>> adj(n);
  for (long long i = 0; i < (m); ++i) {
    long long l, r, d;
    cin >> l >> r >> d;
    l--, r--;
    adj[l].emplace_back(r, d);
    adj[r].emplace_back(l, -d);
  }
  vector<long long> cost(n, -1);
  for (long long i = 0; i < (n); ++i) {
    for (auto v : adj[i]) {
      if (cost[v.first] == -1)
        cost[v.first] = cost[i] + v.second;
      else {
        if (cost[v.first] != cost[i] + v.second) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
