#include <bits/stdc++.h>
using namespace std;
int N, M;
int UF[110000];
int dis[110000];
pair<int, int> FIND(int a) {
  if (UF[a] < 0) return {a, 0};
  pair<int, int> par = FIND(UF[a]);
  dis[a] += par.second;
  UF[a] = par.first;
  return {par.first, dis[a]};
}
bool check(int l, int r, int d) {
  pair<int, int> L = FIND(l);
  pair<int, int> R = FIND(r);
  if (L.first == R.first) {
    if (L.second + d != R.second) {
      return false;
    }
  }
  UF[R.first] = L.first;
  dis[R.first] = d + L.second - R.second;
  return true;
}
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> M;
  for (long long i = 0; i < (N); i++) {
    UF[i] = -1;
  }
  for (long long i = 0; i < (M); i++) {
    int l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    bool res = check(l, r, d);
    if (!res) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
