#include <bits/stdc++.h>
using namespace std;
const int N = 100001;
const int M = 200001;
vector<pair<int, int>> adj[N];
int dist[N];
bool dfs(int u) {
  for (auto el : adj[u]) {
    int v = el.first;
    int d = el.second;
    if (dist[v] == -1) {
      dist[v] = dist[u] + d;
      if (!dfs(v)) return false;
    } else {
      if (dist[u] + d != dist[v]) return false;
    }
  }
  return true;
}
int main() {
  int n, m;
  cin >> n >> m;
  memset(dist, -1, sizeof(dist));
  int u, v, d;
  for (int i = 0; i < m; i++) {
    cin >> u >> v >> d;
    u--, v--;
    adj[u].push_back({v, -d});
    adj[v].push_back({u, d});
  }
  for (int i = 0; i < n; i++) {
    if (dist[i] == -1) {
      dist[i] = 0;
      if (!dfs(i)) {
        cout << "No";
        return 0;
      }
    }
  }
  cout << "Yes";
  return 0;
}
