#include <bits/stdc++.h>
using namespace std;
int const size = 1e5 + 100;
vector<pair<int, int> > ed[size];
int coord[size];
int used[size];
bool dfs(int v) {
  used[v] = 1;
  for (int i = 0; i < (int)ed[v].size(); i++) {
    int u = ed[v][i].first;
    int d = ed[v][i].second;
    if (used[u] == 0) {
      coord[u] = coord[v] + d;
      return dfs(u);
    } else if (coord[u] != coord[v] + d) {
      return false;
    }
  }
  return true;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    ed[l].push_back(make_pair(r, d));
    ed[r].push_back(make_pair(l, -d));
  }
  for (int i = 0; i < n; i++) {
    if (used[i] == 0) {
      if (dfs(i)) continue;
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}
