#include <bits/stdc++.h>
using namespace std;
static const int MAX_N = 100000;
static const int NIL = -1;
struct edge {
  int to, cost;
};
int N, M;
vector<edge> G[MAX_N];
bool flag;
bool visited[MAX_N];
int dist[MAX_N];
void dfs(int s) {
  for (int i = 0; i < G[s].size(); i++) {
    if (dist[G[s][i].to] != NIL && dist[G[s][i].to] != dist[s] + G[s][i].cost) {
      flag = false;
      return;
    } else {
      dist[G[s][i].to] = dist[s] + G[s][i].cost;
      dfs(G[s][i].to);
    }
  }
  return;
}
int main() {
  cin >> N >> M;
  fill(visited, visited + N, false);
  fill(dist, dist + N, NIL);
  for (int i = 0; i < M; i++) {
    int L, R, D;
    cin >> L >> R >> D;
    L--;
    R--;
    G[L].push_back((edge){R, D});
  }
  flag = true;
  for (int i = 0; i < N; i++) {
    dfs(i);
  }
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
