#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to, cost;
};
int N;
int M;
int L[100000];
int R[100000];
int D[100000];
vector<edge> G[100001];
long long d[100001];
bool changed[100001];
void bfs(int s) {
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      que;
  if (d[s] == 20000000000) d[s] = 0;
  changed[s] = true;
  que.push(pair<int, int>(0, s));
  while (!que.empty()) {
    pair<int, int> p = que.top();
    que.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (int i = 0; i < G[v].size(); i++) {
      struct edge e = G[v][i];
      if (d[e.to] == 20000000000) {
        d[e.to] = d[v] + e.cost;
        que.push(pair<int, int>(d[e.to], e.to));
      }
    }
  }
}
int main() {
  scanf("%d %d", &N, &M);
  for (int i = 0; i < M; i++) scanf("%d %d %d", &L[i], &R[i], &D[i]);
  for (int i = 0; i < M; i++) {
    struct edge e;
    e.cost = D[i];
    e.to = R[i];
    G[L[i]].push_back(e);
  }
  for (int i = 0; i < N + 1; i++) changed[i] = false;
  fill(d, d + 100001, 20000000000);
  for (int i = 0; i < M; i++) {
    if (changed[L[i]] == false) bfs(L[i]);
  }
  for (int i = 1; i < N + 1; i++) {
  }
  for (int i = 0; i < M; i++) {
    if (d[R[i]] - d[L[i]] != D[i]) {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}
