#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> Range[100003];
int C[100003];
bool dfs(int x) {
  for (int i = 0; i < Range[x].size(); i++) {
    if (C[Range[x][i].first] == -1) {
      C[Range[x][i].first] = C[x] + Range[x][i].second;
      if (!dfs(Range[x][i].first)) return false;
    } else if (C[Range[x][i].first] != C[x] + Range[x][i].second) {
      return false;
    }
  }
  return true;
}
int main() {
  int N, M;
  cin >> N >> M;
  int l, r, d;
  for (int i = 0; i < M; i++) {
    cin >> l >> r >> d;
    Range[l - 1].push_back(make_pair(r - 1, d));
    Range[r - 1].push_back(make_pair(l - 1, -d));
  }
  for (int i = 0; i < N; i++) C[i] = -1;
  for (int i = 0; i < N; i++) {
    if (C[i] == -1) {
      C[i] = 0;
      if (!dfs(i)) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
