#include <bits/stdc++.h>
using namespace std;
int N, M;
struct edge {
  int to, cost;
  edge(int t, int c) { to = t, cost = c; }
};
int dist[100005];
vector<edge> G[100005];
void dfs(int v, int d) {
  if (dist[v] == 0) {
    dist[v] = d;
    for (auto to : G[v]) {
      dfs(to.to, d + to.cost);
    }
  } else {
    if (dist[v] != d) {
      cout << "No" << endl;
      exit(0);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M;
  for (int i = (0); i < (M); ++i) {
    int l, r, d;
    cin >> l >> r >> d;
    G[l].push_back(edge(r, d));
    G[r].push_back(edge(l, -d));
  }
  for (int i = (1); i < (N + 1); ++i) {
    if (dist[i] == 0) {
      dfs(i, 0);
    }
  }
  cout << "Yes" << endl;
  return 0;
}
