#include <bits/stdc++.h>
using namespace std;
struct A {
  int into, v;
  A() {}
  A(int into, int v) : into(into), v(v) {}
};
const int maxn = 100011;
const long long maxk = 100000000000LL;
vector<A> a[maxn];
long long c[maxn];
int n, m;
bool flag;
bool sf[maxn];
bool diansf[maxn];
bool spfa(int x) {
  for (int i = 1; i <= n; i++) {
    c[i] = maxk;
  }
  memset(sf, false, sizeof(sf));
  c[x] = 0;
  sf[x] = true;
  queue<int> q;
  q.push(x);
  while (!q.empty()) {
    int xx = q.front();
    q.pop();
    diansf[xx] = true;
    sf[xx] = false;
    for (int i = 0; i < a[xx].size(); i++) {
      if (c[a[xx][i].into] != a[xx][i].v + c[xx]) {
        if (c[a[xx][i].into] != maxk) return false;
        c[a[xx][i].into] = a[xx][i].v + c[xx];
        if (!sf[a[xx][i].into]) {
          q.push(a[xx][i].into);
          sf[a[xx][i].into] = true;
        }
      }
    }
  }
  return true;
}
int main(int argc, char *argv[]) {
  int x, y, z;
  flag = true;
  memset(diansf, false, sizeof(diansf));
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &x, &y, &z);
    a[x].push_back(A(y, z));
  }
  for (int i = 1; i <= n; i++) {
    if (!diansf[i]) {
      flag = spfa(i);
      if (!flag) break;
    }
  }
  if (flag)
    puts("Yes");
  else
    puts("No");
}
