#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char ch = getchar();
  int x = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
struct Edge {
  int u, v, w, Next;
} G[100010 * 2];
int head[100010], tot;
inline void add(int u, int v, int w) {
  G[++tot] = (Edge){u, v, w, head[u]};
  head[u] = tot;
}
int d[100010];
bool vis[100010];
inline void dfs(int x) {
  vis[x] = 1;
  for (int i = head[x]; i != -1; i = G[i].Next) {
    if (d[G[i].v] != 2147483647 && d[x] + G[i].w != d[G[i].v]) {
      puts("No");
      exit(0);
    }
    if (!vis[G[i].v]) {
      d[G[i].v] = d[x] + G[i].w;
      dfs(G[i].v);
    }
  }
}
int main() {
  int n = read(), m = read();
  memset(head, -1, sizeof(head));
  for (int i = (1); i <= (n); ++i) d[i] = 2147483647;
  for (int i = (1); i <= (m); ++i) {
    int u = read(), v = read(), D = read();
    add(u, v, D);
    add(v, u, -D);
  }
  for (int i = (1); i <= (n); ++i)
    if (!vis[i]) {
      dfs(i);
    }
  puts("Yes");
  return 0;
}
