#include <bits/stdc++.h>
using namespace std;
int n, m;
int l[100001], r[100001], d[100001];
long long int dist[100001];
bool used[100001];
struct Edge {
  int to, cost;
};
vector<Edge> G[100001];
bool f = true;
void dfs(int v) {
  used[v] = true;
  for (int i = 0; i < G[v].size(); i++) {
    Edge e = G[v][i];
    if (!used[e.to]) {
      dist[e.to] = dist[v] + e.cost;
      dfs(e.to);
    } else {
      if (dist[e.to] - dist[v] != e.cost) f = false;
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> l[i] >> r[i] >> d[i];
    l[i]--;
    r[i]--;
    Edge e;
    e.to = r[i];
    e.cost = d[i];
    G[l[i]].push_back(e);
    e.to = l[i];
    e.cost = -d[i];
    G[r[i]].push_back(e);
  }
  for (int i = 0; i < n; i++) {
    if (!used[i]) dfs(i);
  }
  if (f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
