#include <bits/stdc++.h>
using namespace std;
const long double E = 2.71828182845904523536;
const long double pi = acos(-1);
const double eps = 1e-9;
const long long mod = 1e9 + 7;
const long long inf = 1LL << 30;
const int N = 200100;
vector<pair<int, int> > adj[N];
long long vis[N];
bool ok = 1;
void DFS(int u, long long k) {
  if (vis[u]) {
    if (vis[u] != k) ok = 0;
    return;
  }
  vis[u] = k;
  for (auto v : adj[u]) DFS(v.first, k + (long long)v.second);
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  while (m--) {
    int u, v, d;
    scanf("%d%d%d", &u, &v, &d);
    adj[u].push_back({v, d});
    adj[v].push_back({u, -1 * d});
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      DFS(i, 0);
    }
  }
  if (ok)
    printf("Yes");
  else
    printf("No");
  return 0;
}
