#include <bits/stdc++.h>
const int N = 1e5 + 54;
inline void up(int &x, int y) { x < y ? x = y : 0; }
inline void down(int &x, int y) { x > y ? x = y : 0; }
inline int max(const int x, const int y) { return x > y ? x : y; }
inline int min(const int x, const int y) { return x < y ? x : y; }
int n, m, x, y, flag, head[N], cnt, dis[N], d, deg[N];
struct node {
  int u, v, w;
} edge[N << 2];
inline void add(int x, int y, int z) {
  edge[cnt] = (node){head[x], y, z};
  head[x] = cnt++;
  edge[cnt] = (node){head[y], x, -z};
  head[y] = cnt++;
  ++deg[x], deg[y]++;
}
inline int dfs(int x, int fa) {
  for (int i = head[x]; ~i; i = edge[i].u) {
    int y = edge[i].v;
    if (dis[y]) {
      if (dis[y] != dis[x] + edge[i].w) return 1;
      continue;
    }
    dis[y] = dis[x] + edge[i].w;
    dfs(y, x);
  }
  return 0;
}
int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  memset(head, -1, sizeof head);
  std::cin >> n >> m;
  for (int i = 1; i <= m; ++i) std::cin >> x >> y >> d, add(x, y, d);
  for (int i = 1; i <= n; ++i)
    if (!dis[i] && deg[i] > 0) dis[i] = 1000000010, flag |= dfs(i, 0);
  if (flag)
    std::cout << "No" << '\n';
  else
    std::cout << "Yes" << '\n';
  return 0;
}
