#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int f = 1, x = 0;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') f = -1LL;
  } while (ch < '0' || ch > '9');
  do {
    x = x * 10 + ch - '0';
    ch = getchar();
  } while (ch >= '0' && ch <= '9');
  return f * x;
}
template <class T>
inline void chmax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
inline void chmin(T &a, T b) {
  if (a > b) a = b;
}
inline void swap(int &a, int &b) {
  int c = a;
  a = b;
  b = c;
}
using namespace std;
const int N = 1e5 + 10;
int fa[N], dis[N];
pair<int, int> find(int x) {
  if (!fa[x]) return make_pair(x, 0);
  pair<int, int> tmp = find(fa[x]);
  dis[x] += tmp.second;
  fa[x] = tmp.first;
  return make_pair(fa[x], dis[x]);
}
int n, m;
int main() {
  n = read();
  m = read();
  for (int i = (1); i <= (m); ++i) {
    int l = read(), r = read(), w = read();
    pair<int, int> x = find(l), y = find(r);
    if (x.first == y.first && x.second + w != y.second) {
      puts("No");
      return 0;
    } else if (x.first != y.first) {
      fa[y.first] = x.first;
      dis[y.first] = w - x.second + y.second;
    }
  }
  puts("Yes");
  return 0;
}
