#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const int M = 400005;
int n, m;
int hd[N], nt[M], to[M], dis[M], num = 0;
int deg[N];
int vvis[N];
void conn(int u, int v, int w) {
  deg[v]++;
  nt[num] = hd[u];
  to[num] = v;
  dis[num] = w;
  hd[u] = num++;
}
int len[N];
int que[N * 2], qi, qn;
void go() {
  cin >> n >> m;
  memset(hd, -1, sizeof(hd));
  memset(deg, 0, sizeof(deg));
  memset(vvis, 0, sizeof(vvis));
  for (int i = 0; i < m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--;
    v--;
    conn(u, v, w);
    conn(v, u, -w);
  }
  int cnt = 0;
  int vcnt = 0;
  for (int i = 0; i < n; i++)
    if (vvis[i] == 0) {
      vvis[i] = 1;
      memset(len, 0x7f, sizeof(len));
      qi = qn = 0;
      que[qn++] = i;
      que[qn++] = 0;
      for (; qi < qn;) {
        int u = que[qi++];
        int w = que[qi++];
        vvis[u] = 1;
        for (int j = hd[u]; ~j; j = nt[j]) {
          int v = to[j];
          int vw = dis[j];
          if (vvis[v]) {
            if (w + vw != len[v]) {
              cout << "No" << endl;
              return;
            }
            continue;
          }
          vvis[v] = 1;
          len[v] = w + vw;
          que[qn++] = v;
          que[qn++] = w + vw;
        }
      }
    } else {
      cnt++;
      if (hd[i] > -1) vcnt++;
    }
  cout << "Yes" << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  go();
  return 0;
}
