#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to, cost;
};
int N;
int M;
int L[200000];
int R[200000];
int D[200000];
vector<edge> G[200000];
long long d[200000];
bool changed[200000];
bool bfs(int s) {
  queue<int> q;
  q.push(s);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    changed[u] = true;
    for (int i = 0; i < G[u].size(); i++) {
      int to = G[u][i].to;
      int cost = G[u][i].cost;
      if (!changed[to]) {
        d[to] = d[u] + cost;
        q.push(to);
      } else {
        if (d[to] != d[u] + cost) 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;
    L[i]--;
    R[i]--;
    e.cost = D[i];
    e.to = R[i];
    G[L[i]].push_back(e);
    struct edge e2;
    e2.cost = -D[i];
    e2.to = L[i];
    G[R[i]].push_back(e2);
  }
  for (int i = 0; i < N; i++) changed[i] = false;
  for (int i = 0; i < N; i++) {
    if (changed[i]) continue;
    d[i] = 0;
    if (!bfs(i)) {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}
