#include <bits/stdc++.h>
using namespace std;
int n, m, a, b, c;
int pos[100005], ok[100005];
void fail() {
  printf("No");
  exit(0);
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d %d", &a, &b, &c);
    if (ok[a] && ok[b]) {
      if (pos[b] - pos[a] != c) fail();
    } else if (ok[a]) {
      pos[b] = pos[a] + c;
    } else if (ok[b]) {
      pos[a] = pos[b] - c;
    } else {
      pos[b] = c;
    }
    ok[a] = ok[b] = 1;
  }
  printf("Yes");
}
