#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MAX = 1e5 + 10;
const int INF = 1e9;
const int MOD = 1e9 + 7;
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
struct edge {
  int to;
  ll cost;
};
int N, M;
int L[MAX], R[MAX], D[MAX];
vector<vector<edge> > graph(MAX);
bool used[MAX];
ll w[MAX];
void dfs(int v, ll sum) {
  used[v] = true;
  for (int i = 0; i < graph[v].size(); i++) {
    edge e = graph[v][i];
    if (used[e.to]) continue;
    w[e.to] = sum + e.cost;
    dfs(e.to, sum + e.cost);
  }
}
int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) cin >> L[i] >> R[i] >> D[i];
  edge e;
  for (int i = 0; i < M; i++) {
    e.cost = D[i];
    e.to = R[i];
    graph[L[i]].push_back(e);
    e.cost *= -1;
    e.to = L[i];
    graph[R[i]].push_back(e);
  }
  for (int i = 1; i <= N; i++) {
    if (used[i]) continue;
    dfs(i, 0);
  }
  bool ans = true;
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j < graph[i].size(); j++) {
      if (w[graph[i][j].to] - w[i] != graph[i][j].cost) ans = false;
    }
  }
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}
