#include <bits/stdc++.h>
using namespace std;
long long pos[100005];
pair<pair<int, int>, int> query[200005];
int n, m;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    pos[i] = LONG_LONG_MIN;
  }
  for (int i = 1; i <= m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    if (l < r)
      query[i] = {{l, r}, d};
    else
      query[i] = {{r, l}, -d};
  }
  sort(query + 1, query + m + 1);
  int cnt = 0;
  for (int i = 1; i <= m; i++) {
    int l = query[i].first.first;
    int r = query[i].first.second;
    int d = query[i].second;
    if (pos[l] != LONG_LONG_MIN && pos[r] != LONG_LONG_MIN) {
      if (pos[r] - pos[l] != d) {
        puts("No");
        return 0;
      }
    } else if (pos[l] != LONG_LONG_MIN) {
      pos[r] = pos[l] + d;
    } else if (pos[r] != LONG_LONG_MIN) {
      pos[l] = pos[r] - d;
    } else {
      cnt++;
      if (cnt > 1) {
        puts("Yes");
        return 0;
      }
      pos[l] = 0;
      pos[r] = d;
    }
  }
  puts("Yes");
  return 0;
}
