#include <bits/stdc++.h>
using namespace std;
int UFpare[100004];
int UFrank[100004];
int UFdist[100004];
void UFinit(int n) {
  for (int i = 0; i <= n; i++) {
    UFpare[i] = i;
    UFrank[i] = 0;
    UFdist[i] = 0;
  }
}
int UFroot(int x) {
  if (UFpare[x] == x)
    return x;
  else {
    int r = UFroot(UFpare[x]);
    UFdist[x] += UFdist[UFpare[x]];
    return UFpare[x] = UFroot(UFpare[x]);
  }
}
int UFdista(int x) {
  UFroot(x);
  return UFdist[x];
}
int UFdiff(int x, int y) { return UFdista(y) - UFdista(x); }
bool UFunion(int x, int y, int z) {
  z += UFdista(x);
  z -= UFdista(y);
  x = UFroot(x);
  y = UFroot(y);
  if (x == y) return false;
  if (UFrank[x] < UFrank[y]) swap(x, y), z = -z;
  if (UFrank[x] == UFrank[y]) UFrank[x]++;
  UFpare[y] = x;
  UFdist[y] = z;
  return true;
}
bool UFsame(int x, int y) { return UFpare[x] == UFpare[y]; }
int main() {
  int n, m;
  int l, r, d;
  int x[100003] = {};
  bool ans = 1;
  scanf("%d%d", &n, &m);
  UFinit(n);
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &l, &r, &d);
    if (!ans) continue;
    if (!UFunion(l, r, d)) {
      if (UFdiff(l, r) != d) {
        ans = false;
      }
    }
  }
  for (int i = 1; i < n + 1; i++) {
    printf("%d -> ", UFdist[i]);
  }
  (ans) ? printf("Yes\n") : printf("No\n");
  ;
  return 0;
}
