#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9 + 7;
vector<int> tonari[200005];
struct UnionFind {
  vector<int> par;
  UnionFind(int N) : par(N) {
    for (int i = 0; i < N; i++) par[i] = i;
  }
  int root(int x) {
    if (par[x] == x)
      return x;
    else
      return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx != ry) par[ry] = rx;
  }
  bool sameroot(int x, int y) { return root(x) == root(y); }
};
vector<pair<int, int>> rights[100005];
vector<int> children[100005];
int main() {
  int N, M;
  cin >> N >> M;
  UnionFind uf(N);
  int L, R, D;
  for (int i = 0; i < M; ++i) {
    cin >> L >> R >> D;
    L--;
    R--;
    uf.unite(L, R);
    rights[L].push_back(make_pair(R, D));
  }
  for (int i = 0; i < N; ++i) {
    children[uf.root(i)].push_back(i);
  }
  for (int i = 0; i < N; ++i) {
    if (children[uf.root(i)].size() == 1) continue;
    bool st = true;
    unordered_map<int, int> mp;
    for (auto node : children[uf.root(i)]) {
      if (st && !rights[node].empty()) {
        st = false;
        mp[node] = 0;
      }
      for (auto right : rights[node]) {
        auto itr = mp.find(right.first);
        if (itr == mp.end()) {
          mp[right.first] = mp[node] + right.second;
        } else {
          if (mp[right.first] != mp[node] + right.second) {
            cout << "No" << endl;
            return 0;
          }
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
