#include <bits/stdc++.h>
const int INF = 1000000009;
int n, m;
std::vector<std::pair<int, int> > know[100000];
int pos[100000];
bool used[100000];
bool fill(int a, int p) {
  if (used[a] == true) {
    if (pos[a] == p) {
      return true;
    } else {
      return false;
    }
  } else {
    used[a] = true;
    pos[a] = p;
    for (int i = 0; i < know[a].size(); i++) {
      if (fill(know[a][i].first, p + know[a][i].second) == false) {
        return false;
      }
    }
    return true;
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    know[a].push_back(std::pair<int, int>(b, c));
    know[b].push_back(std::pair<int, int>(a, -c));
  }
  for (int i = 0; i < n; i++) {
    pos[i] = INF;
  }
  for (int i = 0; i < n; i++) {
    if (!used[i]) {
      if (!fill(i, 0)) {
        printf("No\n");
        return 0;
      }
    }
  }
  printf("Yes\n");
  return 0;
}
