#include <bits/stdc++.h>
using namespace std;
template <class T>
using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
struct Edge {
  int to;
  int dist;
  Edge(int _t, int _d) {
    to = _t;
    dist = _d;
  }
};
int N, M;
vector<Edge> G[100010];
map<int, long long> dist;
bool flag;
void dfs(int v, long long depth) {
  if (!flag) return;
  if (dist.find(v) != dist.end() && dist[v] != depth) {
    flag = false;
    return;
  }
  if (dist.find(v) != dist.end() && dist[v] == depth) {
    return;
  }
  dist[v] = depth;
  for (int i = 0; i < G[v].size(); i++) {
    dfs(G[v][i].to, G[v][i].dist + depth);
  }
}
int main() {
  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));
  }
  flag = true;
  for (int i = 1; i <= N; i++) {
    if (dist.find(i) == dist.end()) {
      dfs(i, 0);
    }
  }
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
