#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 10;
const int M = 200000 + 10;
int n, m;
struct node {
  int to, nxt, val;
} e[M];
int head[N], cnt;
int d[N];
bool vis[N], flag = 1;
queue<int> q;
long long dis[N];
void add(int f, int t, int v) {
  cnt++;
  e[cnt] = (node){t, head[f], v};
  head[f] = cnt;
}
void topsort(int t) {
  while (!q.empty()) q.pop();
  q.push(t);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    vis[u] = 1;
    for (int i = head[u]; ~i; i = e[i].nxt) {
      int v = e[i].to;
      if (!vis[v])
        dis[v] = dis[u] + e[i].val, q.push(v);
      else if (dis[v] != dis[u] + e[i].val) {
        flag = 0;
        return;
      }
    }
  }
}
int main() {
  memset(head, -1, sizeof(head));
  scanf("%d%d", &n, &m);
  int x, y, z;
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d%d", &x, &y, &z);
    add(x, y, z);
    d[y]++;
  }
  for (int i = 1; i <= n; ++i) {
    if (!vis[i] && !d[i]) topsort(i);
    if (!flag) break;
  }
  if (flag)
    for (int i = 1; i <= n; ++i) {
      if (!vis[i]) {
        flag = 0;
        break;
      }
    }
  if (flag)
    puts("Yes");
  else
    puts("No");
  return 0;
}
