#include <bits/stdc++.h>
using namespace std;
vector<long long> dir;
vector<vector<pair<long long, long long>>> ad;
bool dfs(long long pos) {
  bool ret = true;
  for (long long i = 0; i < (long long)ad[pos].size(); i++) {
    if (dir[ad[pos][i].first] == 1000000000ll * 1000000000ll) {
      dir[ad[pos][i].first] = dir[pos] + ad[pos][i].second;
      dfs(ad[pos][i].first);
    } else
      ret = ret & (dir[ad[pos][i].first] == dir[pos] + ad[pos][i].second);
  }
  return ret;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  ad.resize(n);
  dir.resize(n);
  for (long long i = 0; i < n; i++) dir[i] = 1000000000ll * 1000000000ll;
  for (long long i = 0; i < m; i++) {
    long long l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    ad[l].push_back(pair<long long, long long>(r, d));
    ad[r].push_back(pair<long long, long long>(l, -d));
  }
  for (long long i = 0; i < n; i++) {
    if (dir[i] == 1000000000ll * 1000000000ll) {
      dir[i] = 0;
      if (!dfs(i)) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
