#include <bits/stdc++.h>
using namespace std;
const int MX = 200020;
const int N = 1000060;
const int mood = ((int)1e9 + 7);
int bst[MX];
bool in[MX];
vector<pair<int, int>> g[MX];
void dfs(int x, int cost) {
  for (auto y : g[x]) {
    if (bst[y.first] == -1) {
      bst[y.first] = cost + y.second;
      dfs(y.first, cost + y.second);
    } else if (bst[y.first] != cost + y.second) {
      cout << "No" << endl;
      exit(0);
    }
  }
}
void remove(int x) {
  for (auto y : g[x]) {
    bst[y.first] = -1;
    remove(y.first);
  }
}
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  if (m == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  while (m--) {
    int a, b, d;
    cin >> a >> b >> d;
    --a, --b;
    g[a].push_back({b, d});
    in[b] = true;
  }
  memset(bst, 0xff, sizeof bst);
  bool found = false;
  for (int i = 0; i < n; ++i) {
    if ((int)g[i].size() && !in[i]) {
      dfs(i, 0);
      found = true;
      remove(i);
    }
  }
  if (found)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
