#include <bits/stdc++.h>
using namespace std;
const static long long int MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};
const static int N = 100000;
int visit[N + 1] = {};
vector<vector<pair<int, int> > > G(N + 1);
int dfs(int x, int cost) {
  visit[x] = 1;
  for (size_t i = 0; i < G[x].size(); i++) {
    if (visit[G[x][i].first] == 1) {
      if (G[x][i].first == x) {
        cost += G[x][i].second;
        if (cost != 0) return 0;
        cost += (-1) * G[x][i].second;
      }
    } else {
      if (G[x][i].second > 0) {
        cost += G[x][i].second;
        if (dfs(G[x][i].first, cost) == 0) return 0;
      }
    }
  }
  return 1;
}
int main(int argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int l, r, d;
  for (int i = 0; i < m; ++i) {
    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 <= n; ++i) {
    if (visit[i] == 1) continue;
    cout << "dfs " << i << endl;
    if (dfs(i, 0) == 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
