#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int n, m, d[10005], f = 1;
vector<pair<int, int>> e[10005] = {};
void dfs(int v) {
  for (int i = 0; i < e[v].size(); i++) {
    int a, b;
    a = e[v][i].first;
    b = e[v][i].second;
    if (d[a] == INF) {
      d[a] = d[v] + b;
      dfs(a);
    } else {
      if (d[a] - d[v] != b) {
        f = 0;
      }
    }
  }
}
int main() {
  for (int i = 0; i < 10005; i++) {
    d[i] = INF;
  }
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int l, r, k;
    cin >> l >> r >> k;
    l--;
    r--;
    e[l].push_back({r, k});
    e[r].push_back({l, -k});
  }
  for (int i = 0; i < n; i++) {
    if (d[i] == INF && !e[i].empty()) {
      d[i] = 0;
      dfs(i);
    }
  }
  if (f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
