#include <bits/stdc++.h>
using namespace std;
int n, m, a[202020], b[202020], x, y, z, t = 0;
int main() {
  cin >> n >> m;
  for (int i = (int)0; i < (int)n; i++) a[i] = b[i] = 0;
  for (int i = (int)0; i < (int)m; i++) {
    cin >> x >> y >> z;
    if (b[y - 1] && a[y - 1] != a[x - 1] + z) t = 1;
    b[y - 1] = 1;
    b[x - 1] = 1;
    a[y - 1] = a[x - 1] + z;
  }
  if (t)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}
