#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6;
const long long int inf = LLONG_MAX;
int n, m, x, y, d;
vector<pair<int, int> > niz[maxn];
pair<pair<int, int>, int> unos[2 * maxn];
long long int poz[maxn];
void bfs(int num) {
  queue<pair<long long int, int> > q;
  q.push(make_pair(0, num));
  while (!q.empty()) {
    int k = q.front().second;
    long long int d = q.front().first;
    q.pop();
    poz[k] = d;
    for (int i = 0; i < niz[k].size(); i++) {
      if (poz[niz[k][i].second] == inf) {
        q.push(make_pair(d + niz[k][i].first, niz[k][i].second));
      }
    }
  }
}
int main() {
  for (int i = 0; i < maxn; i++) poz[i] = inf;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> x >> y >> d;
    unos[i] = make_pair(make_pair(x, y), d);
    niz[x].push_back(make_pair(d, y));
    niz[y].push_back(make_pair(-d, x));
  }
  for (int i = 0; i < n; i++) {
    if (poz[i + 1] == inf) bfs(i + 1);
  }
  long long int mi = 1e18;
  for (int i = 1; i <= n; i++) mi = min(mi, poz[i]);
  for (int i = 1; i <= n; i++) poz[i] -= mi;
  for (int i = 0; i < m; i++) {
    int num1 = unos[i].first.first;
    int num2 = unos[i].first.second;
    int dist = unos[i].second;
    if (poz[num2] - poz[num1] != dist || poz[num1] > 1e9 || poz[num2] > 1e9) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}
