#include <bits/stdc++.h>
using namespace std;
long long int pos[100001], mark[100001];
vector<pair<long long int, long long int> > L[100001], R[100001];
queue<long long int> q;
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  long long int n, m, i, j, k, x, y, z;
  cin >> n >> m;
  for (i = 1; i <= n; ++i) pos[i] = LLONG_MAX;
  long long int root = -1;
  for (i = 0; i < m; ++i) {
    cin >> x >> y >> z;
    if (root == -1) {
      root = x;
    }
    L[y].push_back(make_pair(x, z));
    R[x].push_back(make_pair(y, z));
    mark[x] = mark[y] = 1;
  }
  pos[root] = 0;
  q.push(root);
  while (!q.empty()) {
    x = q.front();
    q.pop();
    for (auto it : L[x]) {
      y = it.first;
      z = it.second;
      if (pos[y] == LLONG_MAX) {
        pos[y] = pos[x] - z;
        q.push(y);
      } else if (pos[y] != pos[x] - z) {
        cout << "No" << endl;
        return 0;
      }
    }
    for (auto it : R[x]) {
      y = it.first;
      z = it.second;
      if (pos[y] == LLONG_MAX) {
        pos[y] = pos[x] + z;
        q.push(y);
      } else if (pos[y] != pos[x] + z) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  for (i = 1; i <= n; ++i)
    if (!mark[i]) pos[i] = 0;
  sort(pos + 1, pos + 1 + n);
  if (pos[1] != LLONG_MAX && pos[n] != LLONG_MAX && pos[n] - pos[1] <= 1e9) {
    cout << "Yes" << endl;
  } else
    cout << "No" << endl;
  return 0;
}
