#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x;
  char c;
  int f = 1;
  while ((c = getchar()) != '-' && (c > '9' || c < '0'))
    ;
  if (c == '-') c = getchar(), f = -1;
  x = c ^ '0';
  while ((c = getchar()) >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + (c ^ '0');
  return x * f;
}
inline long long readll() {
  long long x;
  char c;
  int f = 1;
  while ((c = getchar()) != '-' && (c > '9' || c < '0'))
    ;
  if (c == '-') c = getchar(), f = -1;
  x = c ^ '0';
  while ((c = getchar()) >= '0' && c <= '9')
    x = (x << 1ll) + (x << 3ll) + (c ^ '0');
  return x * f;
}
const int maxn = 1000 + 10;
int fa[maxn], d[maxn];
int n, m, flag;
int find(int x) {
  if (fa[x] == x) return x;
  int y = find(fa[x]);
  d[x] += d[fa[x]];
  return fa[x] = y;
}
void add(int x, int y, int z) {
  int u = find(x), v = find(y);
  if (u != v) {
    fa[u] = v;
    d[u] = d[y] - d[x] - z;
  } else if (d[y] - d[x] != z)
    flag = 1;
}
int main() {
  memset(d, 0, sizeof(d));
  n = read();
  m = read();
  flag = 0;
  for (register int i = 0, iend = n; i <= iend; ++i) fa[i] = i;
  while (m--) {
    int x, y, z;
    x = read(), y = read(), z = read();
    if (!flag) add(x, y, z);
  }
  if (flag)
    printf("No\n");
  else
    printf("Yes\n");
  return 0;
}
