#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 20;
int n, m;
vector<pair<int, int> > adj[maxn];
int bio[maxn];
map<int, int> loc;
bool dfs(int u, int par) {
  bio[u] = 1;
  for (pair<int, int> e : adj[u]) {
    if (e.first != par) {
      if (bio[e.first] == 0) {
        loc[e.first] = loc[u] + e.second;
        dfs(e.first, u);
      } else if (bio[e.first] == 1) {
        if (loc[e.first] != loc[u] + e.second) {
          return true;
        }
      }
    }
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 0, u, v, d; i < m; i++) {
    cin >> u >> v >> d;
    adj[u].push_back(pair<int, int>(v, d));
    adj[v].push_back(pair<int, int>(u, -d));
  }
  for (int i = 1; i <= n; i++) {
    if (!bio[i]) {
      loc[i] = 0;
      if (dfs(i, 0)) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
