#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, m, vis[N], in[N];
vector<int> adj[N];
vector<pair<int, int> > who[N];
vector<int> roots;
map<long long, long long> pos;
int DFS(int u) {
  if (in[u]) return 1;
  vis[u] = 1;
  in[u] = 1;
  int flag = 0;
  for (int i = 0; i < adj[u].size(); ++i) {
    int v = adj[u][i];
    flag = 1;
    if (vis[v]) continue;
    DFS(v);
  }
  if (!flag) roots.push_back(u);
  in[u] = 0;
  return 0;
}
int calc(long long cur, long long p) {
  if (pos.find(cur) != pos.end() && pos[cur] != p) return 1;
  pos[cur] = p;
  for (int j = 0; j < who[cur].size(); ++j) {
    int r = who[cur][j].first;
    long long d = who[cur][j].second;
    if (calc(r, p + d)) return 1;
  }
  return 0;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int l, r, d;
    scanf("%d%d%d", &l, &r, &d);
    --l;
    --r;
    adj[r].push_back(l);
    who[l].push_back(make_pair(r, d));
  }
  for (int i = 0; i < n; ++i)
    if (!vis[i] && DFS(i)) return 0 * puts("No");
  memset(vis, 0, sizeof vis);
  for (int i = 0; i < roots.size(); ++i) {
    int cur = roots[i];
    if (calc(cur, 0)) return 0 * puts("No");
  }
  for (int i = 0; i < n; ++i)
    if (pos.find(i) == pos.end() || pos[i] > 1000000000) return 0 * puts("No");
  puts("Yes");
  return 0;
}
