#include <bits/stdc++.h>
using namespace std;
bool check(int head, int N, vector<pair<int, int>> list[], bool marked[],
           long long pt[], vector<int> &step) {
  if (head == N) return true;
  if (list[head].empty()) {
    if (step.empty()) {
      for (int i = 0; i < N; i++) {
        if (!marked[i] && !list[i].empty()) {
          marked[i] = true;
          return check(i, N, list, marked, pt, step);
        }
      }
      return true;
    } else {
      int prev = step.back();
      step.pop_back();
      return check(prev, N, list, marked, pt, step);
    }
  }
  pair<int, int> to = list[head].back();
  if (marked[to.first] && pt[head] + to.second != pt[to.first]) return false;
  if (marked[to.first]) {
    list[head].pop_back();
    return check(head, N, list, marked, pt, step);
  } else {
    marked[to.first] = true;
    pt[to.first] = pt[head] + to.second;
    step.push_back(head);
    return check(to.first, N, list, marked, pt, step);
  }
}
int main() {
  int N, M;
  vector<pair<int, int>> list[100000];
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    list[l].push_back(make_pair(r, d));
    list[r].push_back(make_pair(l, -d));
  }
  bool marked[100000];
  long long pt[100000];
  for (int i = 0; i < N; i++) {
    marked[i] = false;
    pt[i] = 0;
  }
  marked[0] = true;
  vector<int> step;
  bool result = check(0, N, list, marked, pt, step);
  if (result)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
