#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int M = 2e5 + 5;
int n, m;
int fa[N], dis[N];
int find(int x) {
  if (fa[x] == x) return x;
  int f = fa[x], dt = dis[x] - dis[f];
  fa[x] = find(fa[x]);
  dis[x] = dis[f] + dt;
  return fa[x];
}
bool merge(int a, int b, int d) {
  int f1 = find(a), d1 = dis[a];
  int f2 = find(b), d2 = dis[b];
  if (f1 == f2 && dis[b] - dis[a] != d) return false;
  fa[f2] = f1;
  dis[f2] = d1 + d - d2;
  return true;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) fa[i] = i, dis[i] = 0;
  while (m--) {
    int l, r, d;
    scanf("%d%d%d", &l, &r, &d);
    if (!merge(l, r, d)) return puts("No"), 0;
  }
  return puts("Yes"), 0;
}
