#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const int inf = 1000 * 1000 * 1000;
int n, m, f[N], dis[N], mx[N], mn[N];
int F(int x) {
  if (x == f[x]) return x;
  int t = f[x];
  f[x] = F(f[x]);
  dis[x] += dis[t];
  return f[x];
}
int main() {
  int i, j;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; ++i) f[i] = i, mx[i] = -inf * 2, mn[i] = inf * 2;
  int ok = 1;
  for (i = 1; i <= m; ++i) {
    int l, r, d;
    scanf("%d%d%d", &l, &r, &d);
    if (!ok) continue;
    if (F(l) == F(r)) {
      if (dis[r] - dis[l] != d) ok = 0;
    } else {
      f[F(r)] = F(l);
      F(r);
      dis[r] = d + dis[l];
    }
  }
  for (i = 1; i <= n; ++i) {
    F(i);
    mx[f[i]] = max(mx[f[i]], dis[i]);
    mn[f[i]] = min(mn[f[i]], dis[i]);
    if ((long long)mx[f[i]] - (long long)mn[f[i]] > (long long)inf) ok = 0;
  }
  puts("No");
  return 0;
}
