#include <bits/stdc++.h>
using namespace std;
struct edge {
  int nod, c;
  edge(int nod, int c) : nod(nod), c(c) {}
};
vector<vector<edge>> G;
char viz[100001];
int n, m;
int dg;
int bfs(int nod, int caut, int cost) {
  if (nod == caut) {
    dg = cost;
  }
  for (edge i : G[nod]) {
    if (viz[i.nod] == 0) {
      viz[i.nod] = 1;
      bfs(i.nod, caut, cost + i.c);
    }
  }
  return 0;
}
int main() {
  cin >> n >> m;
  G.resize(n + 1);
  for (int i = 0; i < m; ++i) {
    int l, r, d;
    cin >> l >> r >> d;
    memset(viz, 0, 100001);
    viz[l] = 1;
    dg = 0;
    bfs(l, r, 0);
    if (dg != d && dg != 0) {
      cout << "No\n";
      return 0;
    }
    G[l].push_back(edge(r, d));
    G[r].push_back(edge(l, -d));
  }
  cout << "Yes\n";
}
