#include <bits/stdc++.h>
using namespace std;
long long int n, m, l, r, d;
std::vector<pair<long long int, long long int>> adj[200007];
set<long long int> seen;
long long int parr[200007];
long long int size[200007];
long long int dis[200007];
long long int vis[200007];
long long int vist[200007];
long long int find(long long int u) {
  if (parr[u] == u) return u;
  return parr[u] = find(parr[u]);
}
void init(long long int n) {
  for (long long int i = 1; i <= n; i++) {
    parr[i] = i;
    size[i] = 1;
  }
}
void unify(long long int a, long long int b) {
  a = find(a);
  b = find(b);
  if (a != b) {
    if (size[b] > size[a]) swap(a, b);
    parr[b] = a;
    size[a] += size[b];
  }
}
void reset() {
  for (long long int e : seen) dis[e] = vis[e] = vist[e] = 0;
  seen.clear();
}
void dfs(long long int cur, long long int d) {
  seen.insert(cur);
  vis[cur] = 1;
  dis[cur] = d;
  for (auto e : adj[cur]) {
    if (!vis[e.first]) dfs(e.first, d + e.second);
  }
}
long long int check(long long int cur) {
  vis[cur] = 1;
  long long int res = 1;
  for (auto e : adj[cur]) {
    long long int v = e.first;
    long long int duv = e.second;
    if ((dis[v] - dis[cur]) != duv) {
      return 0;
    }
    if (!vis[e.first]) res &= check(v);
  }
  return 1;
}
int main() {
  std::cin >> n >> m;
  init(n);
  for (long long int i = 0; i < m; i++) {
    std::cin >> l >> r >> d;
    unify(l, r);
    adj[l].push_back({r, d});
    adj[r].push_back({l, -d});
  }
  set<long long int> cc;
  for (long long int i = 1; i <= n; i++) cc.insert(find(i));
  for (long long int e : cc) {
    reset();
    dfs(e, 0);
    if (!check(e)) return 0 * printf("No\n");
  }
  return 0 * printf("Yes\n");
}
