#include <bits/stdc++.h>
struct edge {
  int to, cost;
};
int x[100000];
bool ok[100000];
std::vector<edge> G[100000];
bool dfs(int s, int now) {
  x[s] = now;
  ok[s] = true;
  for (auto e : G[s]) {
    int to = e.to;
    int cost = e.cost;
    if (!ok[to]) {
      if (!dfs(to, now + cost)) {
        return false;
      }
    } else if (x[to] - now != cost) {
      return false;
    }
  }
  return true;
}
int main() {
  int N, M;
  scanf("%d %d", &N, &M);
  for (int i = 0; i < M; ++i) {
    int L, R, D;
    L--;
    R--;
    scanf("%d %d %d", &L, &R, &D);
    G[L].push_back((edge){R, D});
    G[R].push_back((edge){L, -D});
  }
  for (int i = 0; i < N; ++i) {
    ok[i] = false;
    x[i] = 0;
  }
  for (int i = 0; i < N; ++i) {
    if (!ok[i] && !dfs(i, 0)) {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}
