#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
vector<vector<pair<int, int>>> X(100000);
int dest, dist;
bool search(int x, int y, int d) {
  int ss = X[x].size();
  for (int i = 0; i < ss; i++) {
    if (X[x][i].first == y) continue;
    if (X[x][i].first == dest) {
      dist = d + X[x][i].second;
      return true;
    }
    if (search(X[x][i].first, x, d + X[x][i].second)) return true;
  }
  return false;
}
int main() {
  int N, M;
  cin >> N >> M;
  int L, R, D;
  for (int i = 0; i < M; i++) {
    cin >> L >> R >> D;
    L--;
    R--;
    dest = R;
    dist = 0;
    if (search(L, -1, 0)) {
      if (D != dist) {
        cout << "No" << endl;
        return 0;
      }
    } else {
      X[L].push_back({R, D});
      X[R].push_back({L, -D});
    }
  }
  cout << "Yes" << endl;
}
