#include <bits/stdc++.h>
using namespace std;
const int INFINT = 1 << 30;
const long long INFLL = 1LL << 60;
const double EPS = 1e-10;
const int MOD = 1000000007;
const int MAX_N = 100000, MAX_M = 200000;
int N, M;
int L[MAX_M], R[MAX_M], D[MAX_M];
struct edge {
  int to, cost;
};
const int MAX_V = MAX_N + 1, INF = 10000010;
vector<edge> G[MAX_V];
int d[MAX_V];
void rec(int v) {
  for (int i = 0; i < G[v].size(); ++i) {
    edge e = G[v][i];
    if (d[e.to] < INF) continue;
    d[e.to] = d[v] + e.cost;
    rec(e.to);
  }
}
int main() {
  cin >> N >> M;
  for (int(i) = 0; (i) < (M); ++(i)) cin >> L[i] >> R[i] >> D[i];
  set<int> s;
  for (int(i) = 0; (i) < (M); ++(i)) {
    s.insert(L[i]);
    s.insert(R[i]);
    G[L[i]].push_back((edge){R[i], D[i]});
    G[R[i]].push_back((edge){L[i], -D[i]});
  }
  fill(d, d + N + 1, INF);
  for (int i : s) {
    if (d[i] == INF) {
      d[i] = 0;
      rec(i);
    }
  }
  for (int(i) = 0; (i) < (M); ++(i)) {
    if (d[R[i]] - d[L[i]] != D[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
