#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<bool> v(N, false);
  vector<int> pos(N, 0);
  vector<vector<tuple<int, int, int>>> G(N);
  for (int i = int(0); i < int(M); i++) {
    int L, R, D;
    cin >> L >> R >> D;
    L--;
    R--;
    if (L > R) {
      swap(L, R);
      D = -D;
    }
    G[L].push_back(make_tuple(L, R, D));
  }
  queue<tuple<int, int, int>> q;
  int idx = 0;
  vector<bool> ch(N, false);
  while (idx < N && !G[idx].size()) {
    ch[idx] = true;
    idx++;
  }
  if (idx != N) {
    for (int i = int(0); i < int(G[idx].size()); i++) {
      q.push(G[idx][i]);
    }
    ch[idx] = true;
  }
  while (q.size()) {
    tuple<int, int, int> data = q.front();
    q.pop();
    int L = get<0>(data), R = get<1>(data), D = get<2>(data);
    if (ch[L] == false) {
      for (int i = int(0); i < int(G[L].size()); i++) {
        q.push(G[L][i]);
      }
    }
    if (ch[R] == false) {
      for (int i = int(0); i < int(G[R].size()); i++) {
        q.push(G[R][i]);
      }
    }
    bool ot = false;
    if (v[L] == false && v[R] == false) {
      pos[L] = 0;
      pos[R] = pos[L] + D;
    } else if (v[L] == true && v[R] == false) {
      pos[R] = pos[L] + D;
    } else if (v[L] == false && v[R] == true) {
      pos[L] = pos[R] + D;
    } else {
      if (pos[L] + D != pos[R]) {
        ot = true;
      }
    }
    v[L] = v[R] = true;
    ch[L] = ch[R] = true;
    if (ot) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
