#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using ll = long long;
const int NMAX = 100000;
const long long DMMAX = 200000 * 10000;
const long long UNKNOWN = DMMAX * 2;
vector<ll> pos;
vector<vector<P>> conds;
int N, M;
ll minx = 0;
ll maxx = 0;
int dfs(int i) {
  ll x = pos[i];
  for (P p : conds[i]) {
    int j = p.first;
    int d = p.second;
    if (pos[j] == UNKNOWN || pos[j] == x + d) {
      pos[j] = x + d;
      minx = min(minx, pos[j]);
      maxx = max(maxx, pos[j]);
      if (dfs(j) == -1) {
        return -1;
      }
    } else {
      return -1;
    }
  }
  return 0;
}
int main() {
  cin >> N >> M;
  for (int i = 0; i < N; ++i) {
    pos.push_back(UNKNOWN);
    conds.push_back(vector<P>());
  }
  for (int i = 0; i < M; ++i) {
    int l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    if (l > r) {
      int tmp = l;
      l = r;
      r = tmp;
      d *= -1;
    }
    conds[l].push_back(make_pair(r, d));
  }
  bool ok = true;
  for (int i = 0; i < N; ++i) {
    if (pos[i] == UNKNOWN) {
      pos[i] = 0;
      minx = DMMAX * 2;
      maxx = -minx;
      if (dfs(i) == -1 || maxx - minx > 100000000) {
        ok = false;
      }
    }
    if (!ok) break;
  }
  cout << (ok ? "Yes" : "No") << endl;
}
