#include <bits/stdc++.h>
using namespace std;
int dx[8] = {0, 0, -1, 1, 1, 1, -1, -1};
int dy[8] = {-1, 1, 0, 0, 1, -1, 1, -1};
const int SIZE = 100050;
int main() {
  map<int, int> tes, ket;
  int N, M;
  cin >> N >> M;
  if (M == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  vector<tuple<int, int, int> > Q;
  for (int i = 0; i < M; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    Q.push_back(make_tuple(l, r, d));
  }
  sort(Q.begin(), Q.end());
  int a, b, c;
  tie(a, b, c) = Q[0];
  tes[a] = 0;
  tes[b] = c;
  for (int i = 1; i < Q.size(); i++) {
    int l, r, d;
    tie(l, r, d) = Q[i];
    auto L = tes.find(l), R = tes.find(r);
    if (L != tes.end() && R != tes.end()) {
      if (tes[r] - tes[l] != d) {
        cout << "No" << endl;
        return 0;
      }
    }
    if (L != tes.end()) tes[r] = tes[l] + d;
    if (R != tes.end()) tes[l] = tes[r] - d;
  }
  cout << "Yes" << endl;
  return 0;
}
