#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
const int INF = 1e9;
int n, m;
struct node {
  int u, v, w;
} p[N];
int fa[N];
int dist[N];
int np[N];
int find_father(int x) {
  if (x == fa[x]) {
    return x;
  }
  int f = fa[x];
  fa[x] = find_father(fa[x]);
  dist[x] = dist[f] + np[x];
  np[x] = dist[x];
  return fa[x];
}
void merge(int x, int y, int w) {
  int f1 = find_father(x);
  int f2 = find_father(y);
  w -= dist[x] - dist[y];
  fa[f1] = f2;
  np[f1] = w;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) fa[i] = i;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &p[i].u, &p[i].v, &p[i].w);
  }
  for (int i = 1; i <= m; i++) {
    int u = p[i].u, v = p[i].v, w = p[i].w;
    find_father(u);
    find_father(v);
    if (fa[u] != fa[v]) {
      merge(u, v, w);
    } else {
      if (dist[v] - dist[u] != w) {
        printf("No\n");
        return 0;
      }
    }
  }
  printf("Yes\n");
}
