#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;
const int Move[4][2] = {-1, 0, 1, 0, 0, 1, 0, -1};
const int Move_[8][2] = {-1, -1, -1, 0, -1, 1, 0, -1, 0, 1, 1, -1, 1, 0, 1, 1};
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
long long a[maxn];
bool flg = false;
vector<pair<int, int> > E[maxn];
void init() {
  for (int i = 0; i < maxn; i++) a[i] = INF;
}
int n, m;
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 (a[to] != INF) {
      if (a[to] - a[idx] != v) {
        flg = true;
        return;
      } else {
        dfs(to);
        if (flg) return;
      }
    } else {
      a[to] = a[idx] + v;
      dfs(to);
      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));
  }
  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;
}
