#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const double pi = acos(-1.0);
template <class T>
int chkmin(T &a, T b) {
  return a > b ? a = b, 1 : 0;
}
template <class T>
int chkmax(T &a, T b) {
  return a < b ? a = b, 1 : 0;
}
template <class T>
T sqr(T a) {
  return a * a;
}
template <class T>
T mmin(T a, T b) {
  return a < b ? a : b;
}
template <class T>
T mmax(T a, T b) {
  return a > b ? a : b;
}
template <class T>
T aabs(T a) {
  return a < 0 ? -a : a;
}
int read() {
  int s = 0, base = 1;
  char c;
  while (!isdigit(c = getchar()))
    if (c == '-') base = -base;
  while (isdigit(c)) {
    s = s * 10 + (c ^ 48);
    c = getchar();
  }
  return s * base;
}
char WriteIntBuffer[1024];
template <class T>
void write(T a, char end) {
  int cnt = 0, fu = 1;
  if (a < 0) {
    putchar('-');
    fu = -1;
  }
  do {
    WriteIntBuffer[++cnt] = fu * (a % 10) + '0';
    a /= 10;
  } while (a);
  while (cnt) {
    putchar(WriteIntBuffer[cnt]);
    --cnt;
  }
  putchar(end);
}
int to[233333], lst[233333], w[233333], beg[122222], e;
void add(int x, int y, int z) {
  to[++e] = y;
  lst[e] = beg[x];
  beg[x] = e;
  w[e] = z;
}
int ww[122222], vis[122222];
void dfs(int x, int omega) {
  vis[x] = 1;
  ww[x] = omega;
  for (int i = beg[x]; i; i = lst[i]) {
    if (!vis[to[i]])
      dfs(to[i], omega + w[i]);
    else {
      if (ww[to[i]] != omega + w[i]) {
        printf("No\n");
        exit(0);
      }
    }
  }
}
int main() {
  int n, m, u, v, w;
  n = read();
  m = read();
  for (int i = 1; i <= m; ++i) {
    u = read();
    v = read();
    w = read();
    add(u, v, w);
    add(v, u, -w);
  }
  for (int i = 1; i <= n; ++i)
    if (!vis[i]) dfs(i, 0);
  printf("Yes\n");
  return 0;
}
