#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
vector<int> father[MAXN];
map<pair<int, int>, long long> dist;
int N, M, l, r;
long long d;
void dfs(int p, long long n) {
  dist.insert(make_pair(pair<int, int>(p, r), d + n));
  dist.insert(make_pair(pair<int, int>(r, p), -d - n));
  father[r].push_back(p);
  for (int i = 0; i < father[p].size(); i++) {
    int np = father[p][i];
    dfs(np, dist[pair<int, int>(np, p)]);
  }
}
int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> l >> r >> d;
    if (dist.find(pair<int, int>(l, r)) != dist.end()) {
      if (dist[pair<int, int>(l, r)] != d) {
        cout << "No\n";
        return 0;
      } else {
        continue;
      }
    } else {
      dfs(l, 0);
    }
  }
  cout << "Yes\n";
  return 0;
}
