#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
long long n, m, d[100010];
bool viz[100010];
int32_t main() {
  ios_base ::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  cin >> n >> m;
  for (long long i = 1; i <= m; i++) {
    long long l, r, first;
    cin >> l >> r >> first;
    if (viz[l] == 0 && viz[r] == 0)
      viz[l] = viz[r] = 1, d[r] = first;
    else if (viz[l] == 1 && viz[r] == 0)
      viz[r] = 1, d[r] = d[l] + first;
    else if (viz[l] == 0 && viz[r] == 1)
      viz[l] = 1, d[l] = d[r] - first;
    else if (d[r] != d[l] + first)
      return cout << "No", 0;
  }
  cout << "Yes";
}
