#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, m;
int num[N];
bool vis[N];
struct node {
  int u, v, w;
} p[N];
bool cmp(node a, node b) { return a.u < b.u; }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &p[i].u, &p[i].v, &p[i].w);
    if (p[i].u > p[i].v) {
      swap(p[i].u, p[i].v);
      p[i].w = -p[i].w;
    }
  }
  sort(p + 1, p + m + 1, cmp);
  for (int i = 1; i <= m; i++) {
    int u = p[i].u, v = p[i].v, w = p[i].w;
    if (vis[u] && vis[v] && num[u] + w != num[v]) {
      printf("No\n");
      return 0;
    } else {
      num[v] = num[u] + w;
      vis[u] = vis[v] = 1;
    }
  }
  printf("Yes\n");
}
