#include <bits/stdc++.h>
using namespace std;
int fa[100005];
int weight[100005];
int root, sum;
void findroot(int x) {
  sum = 0;
  for (root = x; fa[root] != -1; root = fa[root]) {
    sum += weight[root];
  }
  int temp;
  int t_sum = sum;
  for (; fa[x] != -1;) {
    temp = fa[x];
    fa[x] = root;
    t_sum -= weight[x];
    weight[x] = sum;
    x = temp;
  }
}
bool u(int l, int r, int x) {
  findroot(l);
  int root1 = root;
  int sum1 = sum;
  findroot(r);
  int root2 = root;
  int sum2 = sum;
  if (root1 == root2) {
    if (sum1 - sum2 == x) {
      return false;
    } else {
      return true;
    }
  }
  x -= sum1;
  x += sum2;
  fa[root1] = root2;
  weight[root1] = x;
  return false;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int i;
  for (i = 0; i < n; i++) {
    fa[i] = -1;
    weight[i] = 0;
  }
  for (i = 0; i < m; i++) {
    int l, r, x;
    scanf("%d%d%d", &l, &r, &x);
    l--;
    r--;
    if (u(l, r, x)) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}
