#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
pair<int, int> fa[100001];
int find(int x) {
  if (fa[x].first == x && fa[x].second == 0) return x;
  int t = find(fa[x].first);
  fa[x] = make_pair(t, fa[fa[x].first].second + fa[x].second);
  fa[x].first = t;
  return t;
}
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) fa[i] = make_pair(i, 0);
  for (int i = 1; i <= m; ++i) {
    int l, r, d;
    cin >> l >> r >> d;
    int x = find(l), y = find(r);
    if (x != y) {
      if (x > y)
        fa[x] = make_pair(y, fa[l].second - fa[r].second + d);
      else
        fa[y] = make_pair(x, fa[l].second - fa[r].second + d);
    } else {
      if (fa[r].second - fa[l].second != d) {
        cout << "No";
        return 0;
      }
    }
  }
  cout << "Yes";
}
