#include <bits/stdc++.h>

using namespace std;

#define pii pair < int, int >
#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define ok puts("ok");

const int N = (int)1e5 + 7;

vector < pii > gr[N];
int used[N];

void dfs(int v, int len, int pr) {
  used[v] = len;
  for (auto to : gr[v]) {
    if (pr == to.fr) continue;
//    cout << v << ' ' << to.fr << endl;
    if (used[to.fr] == -1) {
      dfs(to.fr, len + to.sc, v);
    } else if (used[to.fr] != len - to.sc && used[to.fr] != len + to.sc) {
      puts("No");
      exit(0);
    }
  }
}

main () {
  int n, m; scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) used[i] = -1;
  for (int i = 1; i <= m; i++) {
    int l, r, d; scanf("%d %d %d", &l, &r, &d);
    gr[l].pb(mk(r, d));
    gr[r].pb(mk(l, d));
  }
  for (int i = 1; i <= n; i++) {
    if (used[i] == -1) {
      dfs(i, 0, 0);
    }
  }
  puts("Yes");
}
