#include <bits/stdc++.h>
using namespace std;
int fa[100010];
long long dis[100010];
int n, m;
void init() {
  memset(dis, 0, sizeof(dis));
  for (int i = 0; i <= n; i++) fa[i] = i;
}
int find(int x) {
  if (fa[fa[x]] == fa[x])
    return fa[x];
  else {
    fa[x] = find(fa[x]);
    dis[x] += dis[fa[x]];
  }
}
int main() {
  int i, j;
  scanf("%d%d", &n, &m);
  init();
  for (i = 1; i <= m; i++) {
    int u, v;
    long long d;
    scanf("%d%d%lld", &u, &v, &d);
    int f1 = find(u), f2 = find(v);
    if (f1 != f2) {
      if (dis[u] + d > dis[v]) {
        fa[f2] = f1;
        dis[f2] = dis[u] + d - dis[v];
      } else {
        fa[f1] = f2;
        dis[f1] = dis[v] - dis[u] - d;
      }
    } else {
      if (dis[v] - dis[u] != d) {
        printf("No\n");
        return 0;
      }
    }
  }
  printf("Yes\n");
  return 0;
}
