#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<pair<int, int>> mp[100005];
struct p {
  int l, r, d;
};
p ps[200005];
int a[100005];
bool dfs(int l, int r, int d, int pos, int sum, bool f) {
  if (l == pos) {
    if (sum == d) {
      return true;
    }
  }
  for (int j = 0; j < mp[pos].size(); j++) {
    if (a[mp[pos][j].first] != 0) {
      continue;
    }
    a[mp[pos][j].first] = 1;
    if (f) {
      if (mp[pos][j].first <= l) {
        return dfs(l, r, d, mp[pos][j].first, sum += mp[pos][j].second, f);
      }
    } else {
      if (mp[pos][j].first >= l) {
        return dfs(l, r, d, mp[pos][j].first, sum += mp[pos][j].second, f);
      }
    }
  }
  return false;
}
int main() {
  cin >> n >> m;
  int l, r, d;
  for (int i = 0; i < m; i++) {
    cin >> l >> r >> d;
    ps[i].r = r;
    ps[i].l = l;
    ps[i].d = d;
    mp[l].push_back(pair<int, int>(r, d));
    mp[r].push_back(pair<int, int>(l, d));
  }
  if (m == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  queue<int> q;
  for (int i = 0; i < m; i++) {
    r = ps[i].r;
    l = ps[i].l;
    d = ps[i].d;
    bool f = (l - r) > 0;
    if (!dfs(l, r, d, r, 0, f)) {
      cout << "No" << endl;
      return 0;
    }
    memset(a, 0, sizeof(a));
  }
  cout << "Yes" << endl;
  return 0;
}
