#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
vector<pair<int, long long> > graph[maxn];
bool vis[maxn];
int dis[maxn];
bool ok;
void dfs(int u) {
  vis[u] = true;
  for (int i = 0; i < graph[u].size(); i++) {
    int v = graph[u][i].first;
    long long c = graph[u][i].second;
    if (!vis[v]) {
      dis[v] = dis[u] + c;
      dfs(v);
    } else {
      if (dis[v] != dis[u] + c) ok = false;
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  if (m == 0) {
    cout << "Yes\n";
    return 0;
  }
  for (int i = 0; i < m; i++) {
    int l, r;
    long long d;
    scanf("%d %d %lld", &l, &r, &d);
    graph[l].push_back({r, d});
    graph[r].push_back({l, -d});
  }
  ok = true;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      dis[i] = 0;
      dfs(i);
    }
  }
  if (ok) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}
