#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
using ti = tuple<int, int, int>;
using lint = long long;
using ll = pair<lint, lint>;
const int N = 1e5 + 4;
int a[N], b[N], d[N];
vector<ii> ad[N];
int n, m;
bool v1[N], v2[N];
int ro[N];
vector<int> o;
bool ok = true;
void go(int n) {
  v1[n] = true;
  for (auto p : ad[n]) {
    int next = p.first;
    int w = p.second;
    if (!v1[next]) {
      go(next);
    } else if (v1[next] && !v2[next]) {
      ok = false;
    }
  }
  ro[n] = o.size();
  o.push_back(n);
  v2[n] = true;
}
int d2[N];
bool v3[N];
bool solve() {
  for (int i = 1; i <= n; i++) {
    if (!v1[i]) {
      go(i);
    }
  }
  if (!ok) return false;
  reverse(o.begin(), o.end());
  v3[0] = true;
  d2[0] = 0;
  for (int i = 0; i < (int)o.size(); i++) {
    int now = o[i];
    for (int j = 0; j < ad[o[i]].size(); j++) {
      int next = ad[now][j].first;
      int we = ad[now][j].second;
      if (!v3[next]) {
        d2[ro[next]] = d2[i] + we;
        v3[next] = true;
      } else {
        if (d2[i] + we == d2[ro[next]]) {
          return false;
        }
      }
    }
  }
  return true;
}
int main() {
  freopen("in.txt", "r", stdin);
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", a + i, b + i, d + i);
    ad[a[i]].push_back(ii(b[i], d[i]));
  }
  if (solve()) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}
