#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];
bool dfs(int s) {
  changed[s] = true;
  for (int i = 0; i < G[s].size(); i++) {
    struct edge e = G[s][i];
    int p = e.to;
    long long tmp = d[s] + e.cost;
    if (changed[p]) {
      if (tmp != d[p]) return false;
      continue;
    } else {
      d[p] = tmp;
      if (!dfs(p)) return false;
    }
  }
  return true;
}
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);
    e.cost = -D[i];
    e.to = L[i];
    G[R[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 < N; i++) {
    if (changed[i]) continue;
    d[i] = 0;
    if (!dfs(i)) {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}
