#include <bits/stdc++.h>
using namespace std;
long long POW(long long a, long long b) {
  if (b == 0) return 1;
  if (b == 1) return a;
  if (b & 1) return (a * POW(a, b - 1)) % 1000000007LL;
  long long t = POW(a, b / 2);
  return (t * t) % 1000000007LL;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) {
  if (a == 0 || b == 0) return gcd(a, b);
  return a * b / gcd(a, b);
}
int dx[] = {0, -1, 1, 0}, dy[] = {1, 0, 0, -1};
int ddx[] = {0, 0, 1, 1, 1, -1, -1, -1}, ddy[] = {1, -1, 1, 0, -1, 1, 0, -1};
int n, m;
int parent[100001];
int leng[100001];
int find(int a) {
  if (parent[a] < 0) return a;
  find(parent[a]);
  leng[a] += leng[parent[a]];
  return parent[a] = find(parent[a]);
}
void merge(int a, int b, int d) {
  leng[b] = leng[a] + d;
  a = find(a), b = find(b);
  if (a != b) {
    parent[a] += parent[b];
    parent[b] = a;
  }
}
int main() {
  memset(parent, -1, sizeof(parent));
  ;
  scanf("%d%d", &n, &m);
  for (int(i) = (0); (i) <= (m - 1); (i) += (1)) {
    int l, r, d;
    scanf("%d%d%d", &l, &r, &d);
    if (find(l) != find(r)) {
      merge(l, r, d);
    } else {
      if (leng[l] + d != leng[r]) {
        puts("No");
        return 0;
      }
    }
  }
  puts("Yes");
}
