#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 pos[NMax];
op v[2 * NMax];
vector<pair<int, int> > G[NMax];
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});
    G[v[i].r].push_back({v[i].l, -v[i].d});
  }
  queue<int> Q;
  Q.push(1);
  while (!Q.empty()) {
    int node = Q.front();
    Q.pop();
    if (pos[node] == -1) pos[node] = LIM;
    for (auto it : G[node]) {
      if (pos[it.first] == -1) {
        pos[it.first] = pos[node] + it.second;
        Q.push(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;
}
