#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const long long longinf = 1LL << 60;
const int mx = 200010;
const long long mod = 1e9 + 7;
vector<pair<long long, long long>> v[mx];
vector<bool> used(mx, false);
vector<long long> dfs_d(mx, 0);
vector<long long> l(mx), r(mx), d(mx);
void dfs(int x) {
  for (auto to : v[x]) {
    if (used[to.first]) {
      continue;
    }
    used[to.first] = true;
    dfs_d[to.first] = dfs_d[x] + to.second;
    dfs(to.first);
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = (int)(0); i < (int)(m); ++i) {
    cin >> l[i] >> r[i] >> d[i];
    l[i]--;
    r[i]--;
    v[l[i]].emplace_back(pair<long long, long long>(r[i], d[i]));
    v[r[i]].emplace_back(pair<long long, long long>(l[i], -d[i]));
  }
  for (int i = (int)(0); i < (int)(n); ++i) {
    if (!used[i]) {
      used[i] = true;
      dfs(i);
    }
  }
  bool flag = true;
  for (int i = (int)(0); i < (int)(n); ++i) {
    if (d[i] != dfs_d[r[i]] - dfs_d[l[i]]) {
      flag = false;
      break;
    }
  }
  cout << (flag ? "Yes" : "No") << endl;
  return 0;
}
