#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 1;
struct edge {
  int next, d;
};
vector<edge> edges[MAXN];
int used[MAXN];
long long dis[MAXN];
bool dfs(int v) {
  used[v] = 1;
  for (auto e : edges[v])
    if (!used[e.next]) {
      dis[e.next] = dis[v] + e.d;
      dfs(e.next);
    } else if (dis[e.next] != dis[v] + e.d)
      return false;
  return true;
}
void solve() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    edges[l].push_back({r, d});
    edges[r].push_back({l, -d});
  }
  for (int i = 1; i <= n; i++)
    if (!used[i] && !dfs(i)) {
      cout << "No" << endl;
      return;
    }
  cout << "Yes" << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
}
