#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<pair<int, int> > G[100010];
int vis[100010];
bool dfs(int x, int co) {
  if (vis[x]) return vis[x] == co;
  vis[x] = co;
  for (pair<int, int> i : G[x]) {
    if (dfs(i.first, co + i.second) == 0) return false;
  }
  return true;
}
int main() {
  cin >> n >> m;
  if (m == 0) {
    cout << "Yes\n";
    return 0;
  }
  for (int i = 1; i <= m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    G[l].push_back(make_pair(r, d));
    G[r].push_back(make_pair(l, -d));
  }
  for (int i = 1; i <= m; i++) {
    if (vis[i]) continue;
    if (dfs(i, 0) == 0) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}
