#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int MOD = 1e8;
const int N = 1e5 + 5;
const int dir[4][2] = {-1, 0, 1, 0, 0, -1, 0, 1};
long long n, m;
long long fa[N], val[N];
int Find(int x) {
  if (fa[x] == -1) return x;
  int root = Find(fa[x]);
  val[x] += val[fa[x]];
  return fa[x] = root;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  memset(fa, -1, sizeof(fa));
  for (int i = 1; i < m + 1; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    long long tmp1 = Find(u);
    long long tmp2 = Find(v);
    if (tmp1 != tmp2) {
      val[tmp1] = val[v] - w - val[u];
      fa[tmp1] = tmp2;
    }
    if (val[v] - val[u] != w) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}
