#include <bits/stdc++.h>
using namespace std;
const int _max = 200003;
int a[_max];
int main() {
  int i, j, n, m, l, r, d;
  cin >> n >> m;
  int flag = 0;
  memset(a, -1, sizeof(a));
  while (m--) {
    cin >> l >> r >> d;
    if (a[l] == -1 && a[r] == -1) {
      a[l] = 0;
      a[r] = a[l] + d;
    } else if (a[l] == -1 && a[r] != -1)
      a[l] = a[r] - d;
    else if (a[l] != -1 && a[r] == -1)
      a[r] = a[l] + d;
    else if (a[l] + d != a[r]) {
      flag = 1;
      break;
    }
  }
  if (flag == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
