#include <bits/stdc++.h>
using namespace std;
const long long inf = (1ll << 62);
const long long mod = 1e9 + 7;
const int MX = 3e5 + 9;
int n, m, x, y, w, vis[MX], f[MX], dis[MX];
vector<pair<int, int> > v[MX];
vector<int> pars;
void dfs(int x, int d) {
  if (vis[x] == 1) {
    puts("No");
    exit(0);
  }
  vis[x] = 1;
  if (dis[x]) {
    if (dis[x] != d) {
      puts("No");
      exit(0);
    }
  }
  dis[x] = d;
  for (auto pp : v[x]) {
    dfs(pp.first, d + pp.second);
  }
  vis[x] = 2;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &x, &y, &w);
    v[x].push_back({y, w});
  }
  for (int i = 1; i <= n; i++) {
    if (vis[i]) continue;
    dfs(i, 0);
  }
  puts("Yes");
}
