#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to;
  long long cost;
  edge(int i, long long j) { to = i, cost = j; };
};
typedef pair<long long, int> P;
vector<edge> G[100005];
bool dfs(vector<long long int> &d, int e) {
  for (int i = 0; i < G[e].size(); i++) {
    int to = G[e][i].to;
    if (d[to] < 0) d[to] = d[e] + G[e][i].cost;
    if (d[to] >= 0 && d[to] != d[e] + G[e][i].cost) return false;
    if (!dfs(d, to)) return false;
  }
  return true;
}
int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    G[l].push_back(edge(r, d));
  }
  bool res = true;
  for (int i = 0; i < N; i++) {
    vector<long long int> d(N, -1);
    d[i] = 0;
    if (!dfs(d, i)) {
      res = false;
      break;
    }
  }
  if (res)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
