#include <bits/stdc++.h>
using namespace std;
vector<pair<long long int, long long int> > parent_dist(100001,
                                                        make_pair(0, 0));
pair<long long int, long long int> find_root(long long int idx) {
  if (parent_dist[idx].first == 0) {
    return make_pair(idx, 0);
  } else {
    pair<long long int, long long int> to_parent = parent_dist[idx];
    pair<long long int, long long int> to_root = find_root(to_parent.first);
    parent_dist[idx] =
        make_pair(to_root.first, to_root.second + to_parent.second);
    return parent_dist[idx];
  }
}
int main() {
  long long int N, M;
  cin >> N >> M;
  bool flag = true;
  for (int hogehoge = (0); hogehoge < (M); ++hogehoge) {
    long long int L, R, D;
    cin >> L >> R >> D;
    pair<long long int, long long int> L_root = find_root(L);
    pair<long long int, long long int> R_root = find_root(R);
    if (L_root.first == R_root.first) {
      if (R_root.second - L_root.second == D) {
      } else {
        flag = false;
      }
    } else {
      parent_dist[R] = make_pair(L, D);
    }
  }
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
