#include <bits/stdc++.h>
using namespace std;
const int MAX = 100010;
vector<pair<int, int> > edge[MAX];
int visited[MAX];
int d[MAX];
void dfs(int next, int cost) {
  visited[next] = true;
  d[next] = cost;
  for (auto to : edge[next]) {
    if (!visited[to.first])
      dfs(to.first, cost + to.second);
    else {
      if (d[to.first] != cost + to.second) {
        cout << "No" << endl;
        exit(0);
      }
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    long long l, r, d;
    cin >> l >> r >> d;
    edge[l].push_back({r, d});
    edge[r].push_back({l, d});
  }
  for (int i = 1; i < n + 1; i++) {
    dfs(i, 0);
  }
  cout << "Yes" << endl;
}
