#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long MAX_N = 100000;
const long long MAX_M = 200000;
vector<long long> P(MAX_N);
vector<bool> B(MAX_N, false);
vector<vector<pair<long long, long long>>> V(MAX_N);
bool dfs(long long s, long long p) {
  P[s] = p;
  B[s] = true;
  for (auto node : V[s]) {
    long long u = node.first;
    if (!B[u]) {
      dfs(u, p + node.second);
    } else {
      if (p + node.second != P[u]) {
        return 0;
      }
    }
  }
  return 1;
}
int main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> L, R, D;
  long long i, j;
  for (i = 0; i < M; i++) {
    long long l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    V[l].push_back(make_pair(r, d));
    V[r].push_back(make_pair(l, -1 * d));
  }
  for (i = 0; i < N; i++) {
    bool res = 1;
    if (!B[i]) {
      res = dfs(i, 0);
    }
    if (!res) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
