#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const double eps = 1e-9;
const int maxn = 1e5 + 10;
const int maxm = 2e5 + 10;
int fa[maxn], dis[maxn];
inline int read() {
  int x = 0, flag = 1;
  char ch = getchar();
  while (!isdigit(ch) && ch != '-') ch = getchar();
  if (ch == '-') flag = -1, ch = getchar();
  while (isdigit(ch)) x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  return x * flag;
}
int find(int x) {
  if (fa[x] == x) return x;
  int tmp = fa[x];
  fa[x] = find(fa[x]);
  dis[x] += dis[tmp];
  return fa[x];
}
int main() {
  int i, j, k, m, n;
  n = read();
  m = read();
  for (i = 1; i <= n; i++) fa[i] = i;
  for (i = 1; i <= m; i++) {
    int x = read(), y = read(), z = read();
    int u = find(x), v = find(y);
    if (u == v) {
      if (dis[y] - dis[x] != z) {
        puts("No");
        return 0;
      }
    } else {
      dis[v] = dis[y] - dis[x] - z;
      if (dis[v] > 0) swap(u, v);
      dis[v] = abs(dis[v]);
      fa[v] = u;
    }
  }
  puts("Yes");
  return 0;
}
