#include <bits/stdc++.h>
using namespace std;
int const maxn = 1e5 + 10;
struct bkn {
  int to, next;
  long long v;
} e[2 * maxn];
int head[maxn], tot = 1;
void add(int a, int b, int v) {
  e[tot].to = b, e[tot].next = head[a], e[tot].v = v, head[a] = tot++;
}
int dp[maxn], q[maxn], cnt, vis[maxn];
void dfs(int x) {
  vis[x] = 1;
  for (int i = head[x]; i; i = e[i].next) {
    int y = e[i].to;
    if (vis[y]) continue;
    dfs(y);
  }
  q[++cnt] = x;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  while (m--) {
    int x, y;
    long long v;
    scanf("%d%d%lld", &x, &y, &v);
    add(x, y, v);
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) dfs(i);
  }
  for (int i = cnt; i >= 1; i--) {
    for (int j = head[i]; j; j = e[j].next) {
      int y = e[j].to;
      if (!dp[i])
        dp[i] = dp[y] + e[j].v;
      else if (dp[i] != dp[y] + e[j].v) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}
