#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int f = 1, res = 0, ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') res = res * 10 + ch - 48, ch = getchar();
  return f * res;
}
const int N = 100005;
const int M = 2 * N;
int n, m, fa[N], dis[N];
inline int find(int u) {
  if (fa[u] != u) {
    int res = find(fa[u]);
    dis[u] += dis[fa[u]];
    fa[u] = res;
  }
  return fa[u];
}
inline int Merge(int x, int y, int d) {
  int fx = find(x), fy = find(y);
  if (fx != fy) {
    dis[fx] = d - dis[x] + dis[y];
    fa[fx] = fy;
    return 1;
  }
  if (dis[x] + dis[y] != d) return -1;
  return 0;
}
int main() {
  n = read(), m = read();
  for (int i = 1, _Lim = n; i <= _Lim; i++) fa[i] = i, dis[i] = 0;
  for (int i = 1, _Lim = m; i <= _Lim; i++) {
    int x = read(), y = read(), d = read();
    if (Merge(x, y, d) == -1) return puts("No"), 0;
  }
  puts("Yes");
}
