#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const long long mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
inline char nc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
template <class T>
inline void read(T &first) {
  char c = nc(), b = 1;
  for (; !(c >= '0' && c <= '9'); c = nc())
    if (c == '-') b = -1;
  for (first = 0; c >= '0' && c <= '9'; first = first * 10 + c - '0', c = nc())
    ;
  first *= b;
}
struct Edge {
  int u, v, w;
} E[2 * N];
int flag[N], vis[N];
int dis[N];
void solve() {
  int n, m;
  long long u, v, w;
  cin >> n >> m;
  memset(flag, 0, sizeof(flag));
  memset(vis, 0, sizeof(vis));
  for (int i = 0; i < m; i++) {
    cin >> u >> v >> w;
    E[i].u = u;
    E[i].v = v;
    E[i].w = w;
    flag[u] = flag[v] = 1;
    vis[v] = 1;
  }
  int k = 0, ans = 1;
  for (int i = 1; i <= n; i++) {
    if (flag[i] && !vis[i]) {
      dis[i] = 0;
    }
  }
  for (int i = 0; i < m; i++) {
    u = E[i].u;
    v = E[i].v;
    w = E[i].w;
    if (dis[u] == 0) {
      dis[v] = 0 - w;
    }
  }
  for (int i = 0; i < m; i++) {
    u = E[i].u;
    v = E[i].v;
    w = E[i].w;
    dis[v] = dis[u] - w;
  }
  for (int i = 0; i < m; i++) {
    u = E[i].u;
    v = E[i].v;
    w = E[i].w;
    if (w != (dis[u] - dis[v])) ans = 0;
  }
  if (ans)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}
