#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;
struct edge {
  int to;
  int cost;
  edge(int to, int cost) : to(to), cost(cost) {}
};
void dfs(vector<vector<edge> > &G, int st, vector<int> &x) {
  x[st] = 0;
  stack<int> S;
  int N = G.size();
  vector<vector<edge>::iterator> itr(N);
  for (int i = 0; i < (N); i++) {
    itr[i] = G[i].begin();
  }
  vector<int> done(N, 0);
  S.push(st);
  while (!S.empty()) {
    int u = S.top();
    if (itr[u] == G[u].end()) {
      S.pop();
      done[u] = 2;
    } else {
      edge v = *itr[u]++;
      if (!done[v.to]) {
        done[v.to] = 1;
        S.push(v.to);
        x[v.to] = x[u] + v.cost;
      }
    }
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<vector<edge> > G(N);
  for (int i = 0; i < (M); i++) {
    int l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    G[l].push_back(edge(r, d));
    G[r].push_back(edge(l, -d));
  }
  vector<int> x(N, -1);
  for (int i = 0; i < (N); i++) {
    if (x[i] == -1) dfs(G, i, x);
  }
  for (int l = 0; l < (N); l++) {
    for (auto e : G[l]) {
      if (x[e.to] - x[l] != e.cost) {
        puts("No");
        return 0;
      }
    }
  }
  puts("Yes");
  return 0;
}
