#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > edge[100000 + 1];
bool visited[100000 + 1];
int dist[100000 + 1];
bool dfs(int v) {
  visited[v] = true;
  for (int i = 0; i < edge[v].size(); ++i) {
    int next = edge[v][i].first;
    int cost = edge[v][i].second;
    if (!visited[next]) {
      dist[next] = dist[v] + cost;
      if (!dfs(next)) {
        return false;
      }
    } else {
      if (dist[next] != dist[v] + cost) {
        return false;
      }
    }
  }
  return true;
}
int main(void) {
  int N, M;
  cin >> N >> M;
  if (M == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  for (int i = 0; i < M; ++i) {
    int l, r, val;
    cin >> l >> r >> val;
    edge[l].push_back(make_pair(r, val));
    edge[r].push_back(make_pair(l, -val));
  }
  memset(visited, false, sizeof(visited));
  for (int i = 1; i < N; ++i) {
    if (!visited[i]) {
      dist[i] = 0;
      if (!dfs(i)) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
