#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T>
void chkmax(T &x, T y) {
  x = max(x, y);
}
template <typename T>
void chkmin(T &x, T y) {
  x = min(x, y);
}
long long qpow(long long x, long long y, long long MOD) {
  long long a = 1;
  while (y) {
    if (y & 1) a = a * x % MOD;
    x = x * x % MOD;
    y >>= 1;
  }
  return a;
}
int p[N], n, m;
long long dis[N];
int Find(int x) {
  if (x != p[x]) {
    int rt = Find(p[x]);
    dis[x] += dis[p[x]];
    p[x] = rt;
  }
  return p[x];
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = int(1); i <= int(n); ++i) p[i] = i;
  int flag = 1;
  while (m--) {
    int x, y, d;
    scanf("%d%d%d", &x, &y, &d);
    int fx = Find(x), fy = Find(y);
    if (fx != fy) {
      p[fx] = fy;
      dis[fx] = d;
    } else {
      if (dis[x] - dis[y] != d) {
        flag = 0;
      }
    }
  }
  if (flag)
    puts("Yes");
  else
    puts("No");
  return 0;
}
