#include <bits/stdc++.h>
using namespace std;
struct ques {
  int l, r, d;
} q[200100];
int n, m;
int d[100100], vis[100100];
bool flag = 1;
bool cmp(ques a, ques b) {
  if (a.l == b.l) return a.r < b.r;
  return a.l < b.l;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) scanf("%d%d%d", &q[i].l, &q[i].r, &q[i].d);
  sort(q + 1, q + m + 1, cmp);
  d[q[1].l] = 0;
  vis[q[1].l] = 1;
  for (int i = 1; i <= m; i++) {
    int x = q[i].l, y = q[i].r, z = q[i].d;
    if (vis[x] && vis[y]) {
      if (d[y] - d[x] != z) {
        flag = 0;
        puts("No");
        break;
      }
    } else if (vis[x]) {
      vis[y] = 1;
      d[y] = d[x] + z;
    } else if (vis[y]) {
      vis[x] = 1;
      d[x] = d[y] - z;
    }
  }
  if (flag) puts("Yes");
  return 0;
}
