#include <bits/stdc++.h>
using namespace std;
const int maxn = 200009, INF = 2e9;
int d[maxn], q[maxn], l, r, a, b, c, n, m, u;
vector<pair<int, int> > e[maxn];
void bfs(int s) {
  l = r = 0;
  q[r++] = s;
  d[s] = 0;
  while (l < r) {
    u = q[l++];
    for (auto k : e[u])
      if (d[k.first] >= INF) {
        d[k.first] = d[u] + k.second;
        q[r++] = k.first;
      } else if (d[u] + k.second != d[k.first]) {
        puts("No");
        exit(0);
      }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (1); i <= int(m); i++) {
    scanf("%d%d%d", &a, &b, &c);
    e[a].push_back(make_pair(b, c));
    e[b].push_back(make_pair(a, -c));
  }
  memset(d, 0x7f, sizeof d);
  for (int i = (1); i <= int(m); i++)
    if (d[i] >= INF) bfs(i);
  puts("Yes");
  return 0;
}
