#include <bits/stdc++.h>
using namespace std;
struct Vertex {
  vector<pair<int, long long> > to;
  long long pos;
  bool flag;
};
long long invalidVal = 1000000005;
int main() {
  int N, M;
  cin >> N >> M;
  unordered_set<long long> segment;
  vector<Vertex> vertex;
  segment.reserve(M * 2);
  vertex.resize(N);
  int L, R, D;
  for (size_t i = 0; i < M; i++) {
    cin >> L >> R >> D;
    L -= 1;
    R -= 1;
    segment.emplace(min(L, R) * N + max(L, R));
    vertex[L].to.push_back(make_pair(R, D));
    vertex[R].to.push_back(make_pair(L, -D));
  }
  for (size_t i = 0; i < N; i++) {
    vertex[i].pos = invalidVal;
    vertex[i].flag = false;
  }
  queue<int> que;
  while (segment.size()) {
    int nn = (*segment.begin()) / N;
    que.push(nn);
    vertex[nn].pos = 0;
    while (que.size()) {
      int n = que.front();
      for (pair<int, long long> seg : vertex[n].to) {
        int m = seg.first;
        long long p = min(m, n) * N + max(m, n);
        if (segment.count(p)) {
          segment.erase(p);
          if (vertex[m].pos == invalidVal) {
            que.push(m);
            vertex[m].pos = vertex[n].pos + seg.second;
          } else {
            if (vertex[m].pos != vertex[n].pos + seg.second) {
              cout << "No";
              goto END;
            }
          }
        }
      }
      que.pop();
    }
  }
  cout << "Yes";
END:
  return 0;
}
