#include <bits/stdc++.h>
using namespace std;
long long name[100001], dist[100001], nxt[100001], sz[100001];
long long n, m;
long long temp1, temp2, temp3;
void merge(long long u, long long v, long long d) {
  long long nx = nxt[u];
  long long siz = sz[name[v]];
  nxt[u] = v;
  name[v] = name[u];
  long long temp = v;
  dist[temp] = dist[u] + d;
  while (nxt[temp] != v) {
    temp = nxt[temp];
    name[temp] = name[u];
    dist[temp] = dist[u] - dist[v] + d;
  }
  nxt[temp] = nx;
  sz[name[u]] += siz;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i <= n; ++i) {
    name[i] = i;
    sz[i] = 1;
    dist[i] = 0;
    nxt[i] = i;
  }
  long long u, v, d;
  for (int i = 0; i < m; ++i) {
    cin >> u >> v >> d;
    if (name[u] == name[v]) {
      if (dist[v] - dist[u] != d) {
        cout << "No";
        return 0;
      }
      continue;
    }
    if (sz[name[u]] > sz[name[v]]) {
      merge(u, v, d);
    } else {
      merge(v, u, -d);
    }
  }
  cout << "Yes";
  return 0;
}
