#include <bits/stdc++.h>
using namespace std;
long long N, M;
int main(int argc, char const *argv[]) {
  cin >> N >> M;
  map<long long, long long> dic;
  for (int i = 0; i < M; ++i) {
    long long l, r, d;
    cin >> l >> r >> d;
    if (dic.count(l)) {
      if (dic.count(r)) {
        if (dic[r] - dic[l] != d) {
          cout << "No" << endl;
          return 0;
        }
      } else {
        dic[r] = dic[l] + d;
      }
    } else if (dic.count(r)) {
      dic[l] = dic[r] - d;
    } else {
      dic[l] = 0;
      dic[r] = d;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
