#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int n, m, top, vis[N], dis[N], head[N];
struct node {
  int too, Next, zh;
} edge[N];
void add(int a, int b, int c) {
  edge[++top].too = b;
  edge[top].zh = c;
  edge[top].Next = head[a];
  head[a] = top;
}
inline int read() {
  int ret = 0, f = 0;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = 1;
    c = getchar();
  }
  while (isdigit(c)) {
    ret = ret * 10 + c - 48;
    c = getchar();
  }
  if (f) return -ret;
  return ret;
}
void dfs(int u, int dep, int id) {
  vis[u] = id;
  dis[u] = dep;
  for (int i = head[u]; i; i = edge[i].Next) {
    int v = edge[i].too, w = edge[i].zh;
    if (!vis[v]) {
      dfs(v, dep + w, id);
      continue;
    }
    if (vis[v] != id) continue;
    if ((dis[v] - dis[u]) != w) {
      puts("No");
      exit(0);
    }
  }
}
signed main() {
  n = read(), m = read();
  for (int i = 1; i <= m; i++) {
    int x = read(), y = read(), z = read();
    add(x, y, z);
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i, 0, i);
  puts("Yes");
}
