#include <bits/stdc++.h>
using namespace std;
int n, m, l, r, d, a[100005];
bool v[100005];
vector<int> ve[100005], vd[100005];
void f(int p) {
  int i;
  for (i = 0; i < ve[p].size(); i++) {
    if (!v[ve[p][i]])
      v[ve[p][i]] = 1, a[ve[p][i]] = a[p] + vd[p][i], f(ve[p][i]);
    else if (a[p] + vd[p][i] != a[ve[p][i]]) {
      cout << "No";
      exit(0);
    }
  }
}
int main() {
  cin >> n >> m;
  while (m--) {
    scanf("%d %d %d", &l, &r, &d);
    ve[l].push_back(r);
    vd[l].push_back(d);
    ve[r].push_back(l);
    vd[r].push_back(-d);
  }
  v[l] = 1;
  f(l);
  cout << "Yes" << endl;
  return 0;
}
