#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10, INF = 1000000009;
long long a[maxn];
bool flg = false;
vector<pair<int, long long> > E[maxn];
void init() {
  for (int i = 0; i < maxn; i++) a[i] = INF;
}
int n, m;
bool vis[maxn];
void dfs(int idx) {
  for (int i = 0; i < E[idx].size(); i++) {
    int to = E[idx][i].first;
    int v = E[idx][i].second;
    if (vis[to]) continue;
    if (a[to] != INF) {
      if (a[to] - a[idx] != v) {
        flg = true;
        return;
      } else {
        if (flg) return;
      }
    } else {
      a[to] = a[idx] + v;
      vis[to] = true;
      dfs(to);
      if (flg) return;
    }
  }
  vis[idx] = true;
  if (flg) return;
}
int L[maxn];
int main() {
  ios_base::sync_with_stdio(0);
  init();
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    L[i] = l;
    E[l].push_back(make_pair(r, d));
    E[r].push_back(make_pair(l, -d));
  }
  for (int i = 0; i < n; i++) {
    if (E[L[i]].size() >= 1) {
      a[L[i]] = 0;
      dfs(L[i]);
      break;
    }
  }
  if (flg)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}
