#include <bits/stdc++.h>
using namespace std;
const int MAX = 200000;
typedef struct people {
  int x;
  bool c;
  vector<pair<int, int> > V;
} People;
bool DFS(People p[], int n) {
  p[n].c = true;
  for (int i = 0; i < p[n].V.size(); i++) {
    if (!p[p[n].V[i].first].c) {
      p[p[n].V[i].first].x = p[n].x + p[n].V[i].second;
      DFS(p, p[n].V[i].first);
    } else if (p[p[n].V[i].first].x == p[n].x + p[n].V[i].second)
      continue;
    else
      return true;
  }
  return false;
}
int main() {
  int N, M, L, R, D;
  cin >> N >> M;
  static People p[MAX + 1];
  for (int i = 1; i <= N; i++) {
    p[i].c = false;
  }
  for (int i = 0; i < M; i++) {
    cin >> L >> R >> D;
    p[L].V.push_back(make_pair(R, D));
    p[R].V.push_back(make_pair(L, -D));
  }
  for (int i = 1; i <= N; i++) {
    if (p[i].c) continue;
    p[i].x = 0;
    if (DFS(p, i)) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}
