#include <bits/stdc++.h>
using namespace std;
const int maxn = 101000;
struct edge {
  int v, next, w;
} e[200010 * 2];
int head[maxn], k, f[maxn];
int flag = 1, vis[maxn], dis[maxn];
void adde(int u, int v, int w) {
  e[k].v = v;
  e[k].w = w;
  e[k].next = head[u];
  head[u] = k++;
}
void dfs(int u, int fa) {
  if (vis[u] == 1) return;
  vis[u] = 1;
  for (int i = head[u]; i != -1; i = e[i].next) {
    int v = e[i].v;
    if (v == fa) continue;
    if (vis[v] && dis[v] != dis[u] + e[i].w) flag = 0;
    dis[v] = dis[u] + e[i].w;
    dfs(v, u);
  }
}
void init() {
  memset(e, 0, sizeof(e));
  memset(head, -1, sizeof(head));
  k = 0;
  memset(f, -1, sizeof(f));
  flag = 1;
}
int main() {
  int n, m, u, v, w;
  init();
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &u, &v, &w);
    f[v] = u;
    adde(u, v, w);
    adde(v, u, -w);
  }
  for (int i = 0; i <= n; i++) {
    if (f[i] == -1) {
      memset(vis, 0, sizeof(vis));
      memset(dis, 0, sizeof(dis));
      dfs(i, 0);
      if (flag == 0) {
        printf("No\n");
        break;
      }
    }
  }
  if (flag) printf("Yes\n");
  return 0;
}
