#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 30, Mod = 1e9 + 7;
const long long SQ = 330;
vector<pair<long long, long long> > G[N];
long long in[N], H[N];
struct Event {
  long long l, r, len;
} E[N];
void DFS(long long x, long long h = 1) {
  H[x] = 1;
  for (auto u : G[x]) {
    if (!H[u.first]) DFS(u.first, h + u.second);
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  long long n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> E[i].l >> E[i].r >> E[i].len;
    G[E[i].l].push_back({E[i].r, E[i].len});
    in[E[i].r] = 1;
  }
  for (int i = 1; i <= n; i++) {
    if (!in[i]) DFS(i);
  }
  for (int i = 1; i <= m; i++) {
    if (H[E[i].l] + E[i].len != H[E[i].r]) return cout << "No", 0;
  }
  cout << "Yes";
  return (0);
}
