#include <bits/stdc++.h>
const int dx[4] = {-1, 1, 0, 0}, dy[4] = {0, 0, -1, 1};
const double eps = 1e-16;
const int N = 500005;
int n, m, head[N], now = 0, vis[N], lev[N];
using namespace std;
struct node {
  int t, w, next;
} adj[N << 1];
void add(int s, int t, int w) {
  adj[++now] = (node){t, w, head[s]};
  head[s] = now;
}
inline int read() {
  char c;
  int x;
  while (c = getchar(), c < '0' || c > '9')
    ;
  x = c ^ '0';
  while (c = getchar(), c >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + (c ^ '0');
  return x;
}
void write(int x) {
  if (x == 0) return;
  write(x / 10);
  putchar((x % 10) + '0');
}
int ans = 1;
void dfs(int s) {
  vis[s] = 1;
  int i;
  for (i = head[s]; i; i = adj[i].next)
    if (!vis[adj[i].t])
      lev[adj[i].t] = lev[s] + adj[i].w, dfs(adj[i].t);
    else if (lev[adj[i].t] != lev[s] + adj[i].w)
      ans = 0;
}
int main() {
  scanf("%d %d", &n, &m);
  int i, s, t, w;
  for (i = 1; i <= m; i++) {
    scanf("%d %d %d", &s, &t, &w);
    add(s, t, w);
  }
  for (i = 1; i <= n; i++)
    if (!vis[i]) dfs(i);
  if (ans)
    puts("Yes");
  else
    puts("No");
  return 0;
}
