#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void amin(T &x, const T &y) {
  if (y < x) x = y;
}
template <class T>
inline void amax(T &x, const T &y) {
  if (x < y) x = y;
}
template <class Iter>
void rprintf(const char *fmt, Iter begin, Iter end) {
  for (bool sp = 0; begin != end; ++begin) {
    if (sp)
      putchar(' ');
    else
      sp = true;
    printf(fmt, *begin);
  }
  putchar('\n');
}
template <class T>
struct UnionFindDiff {
  int n;
  vector<int> U;
  vector<T> D;
  UnionFindDiff() {}
  UnionFindDiff(int n_) : n(n_), U(n, -1), D(n, T(0)) {}
  int root(int x) {
    if (U[x] < 0) return x;
    int r = root(U[x]);
    if (U[x] != r) {
      D[x] = D[U[x]] + D[x];
      U[x] = r;
    }
    return r;
  }
  int link(int x, int y, T diff) {
    int p, q;
    p = root(x);
    q = root(y);
    if (p == q) return p;
    if (U[q] < U[p]) {
      swap(p, q);
      swap(x, y);
      diff = -diff;
    }
    D[q] = D[x] - D[y] + diff;
    U[p] += U[q];
    n--;
    return U[q] = p;
  }
  bool same(int x, int y) { return root(x) == root(y); }
  int size(int x) { return -U[root(x)]; }
  int count() { return n; }
  T diff(int x, int y) { return D[y] - D[x]; }
};
int N, M;
int L[200111], R[200111], D[200111];
void MAIN() {
  scanf("%d%d", &N, &M);
  for (int i = 0, i_len = (M); i < i_len; ++i)
    scanf("%d%d%d", L + i, R + i, D + i), L[i]--, R[i]--;
  UnionFindDiff<int> U(N);
  for (int i = 0, i_len = (M); i < i_len; ++i) {
    U.link(R[i], L[i], D[i]);
  }
  bool yes = true;
  for (int i = 0, i_len = (M); i < i_len; ++i) {
    if (D[i] != U.diff(R[i], L[i])) {
      yes = false;
      break;
    }
  }
  puts(yes ? "Yes" : "No");
}
int main() {
  int TC = 1;
  for (int tc = 0, tc_len = (TC); tc < tc_len; ++tc) MAIN();
  return 0;
}
