#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<pair<int, int>> adj[100005];
int dist[100000];
bool vis[100000];
void dfs(int u, int cur) {
  if (vis[u]) {
    if (dist[u] != cur) {
      cout << "No\n";
      exit(0);
    }
    return;
  }
  vis[u] = 1;
  dist[u] = cur;
  for (auto v : adj[u]) dfs(v.first, cur + v.second);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> N >> M;
  while (M--) {
    int u, v, w;
    cin >> u >> v >> w;
    adj[u].push_back(make_pair(v, w));
    adj[v].push_back(make_pair(u, -w));
  }
  for (int i = 1; i <= N; i++)
    if (!vis[i]) dfs(i, 0);
  cout << "Yes\n";
}
