#include <bits/stdc++.h>
#pragma warning(disable : 4786)
#pragma warning(disable : 4996)
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
const long long int MOD = 1000000007;
const long long int INF = 2000000000000000001LL;
const long long int P = 8738843;
int par[100005], cost[100005];
pair<int, int> Par(int at) {
  if (at == par[at]) return {at, 0};
  pair<int, int> u = Par(par[at]);
  cost[at] += u.second;
  return {u.first, cost[at]};
}
void Join(int a, int b, int d) {
  pair<int, int> A = Par(a);
  pair<int, int> B = Par(b);
  if (A.first == B.first) {
    if (A.second + d != B.second) {
      printf("No\n");
      exit(0);
    }
  } else {
    int x = d - B.second + A.second;
    cost[B.first] = x;
    par[B.first] = A.first;
  }
}
void solve(int ks) {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) par[i] = i;
  while (m--) {
    int u, v, d;
    scanf("%d %d %d", &u, &v, &d);
    Join(u, v, d);
  }
  printf("Yes\n");
}
void gen() {}
int main() {
  gen();
  if (0) {
    int T;
    scanf("%d", &T);
    for (int ks = 1; ks <= T; ks++) {
      solve(ks);
    }
  } else {
    solve(0);
  }
  return 0;
}
