#include <bits/stdc++.h>
using namespace std;
inline void Boost() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
const int NMax = 1e5 + 50;
const int LIM = 1e9;
struct op {
  int l, r, d;
};
int in[NMax];
int pos[NMax];
op v[2 * NMax];
vector<pair<int, int> > G[NMax];
vector<pair<int, int> > revG[NMax];
void Rever(int node) {
  for (auto it : revG[node]) {
    if (pos[it.first] == -1) {
      pos[it.first] = pos[node] - it.second;
      Rever(it.first);
    }
  }
}
int main() {
  Boost();
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) pos[i] = -1;
  for (int i = 1; i <= m; ++i) {
    cin >> v[i].l >> v[i].r >> v[i].d;
    G[v[i].l].push_back({v[i].r, v[i].d});
    revG[v[i].r].push_back({v[i].l, v[i].d});
    in[v[i].r]++;
  }
  queue<int> Q;
  for (int i = 1; i <= n; ++i) {
    if (in[i] == 0) {
      Q.push(i);
    }
  }
  while (!Q.empty()) {
    int now = Q.front();
    Q.pop();
    if (pos[now] == -1) pos[now] = LIM;
    for (auto it : G[now]) {
      if (pos[it.first] == -1) {
        pos[it.first] = pos[now] + it.second;
        Q.push(it.first);
        Rever(it.first);
      }
    }
  }
  for (int i = 1; i <= m; ++i) {
    if (pos[v[i].r] - pos[v[i].l] != v[i].d) {
      cout << "No";
      exit(0);
    }
  }
  cout << "Yes";
  return 0;
}
