#include <bits/stdc++.h>
using namespace std;
long long n, m, poz[1000000 + 100], maxx, minx;
bool obidjen[1000000 + 100];
struct node {
  long long l, r, d;
};
node a[1000000 + 100];
vector<pair<int, int>> v[1000000 + 100];
map<pair<int, int>, int> mapa;
void dfs(int x) {
  obidjen[x] = 1;
  for (int i = 0; i < v[x].size(); i++) {
    int y = v[x][i].first;
    if (obidjen[y]) continue;
    obidjen[y] = 1;
    poz[y] = v[x][i].second + poz[x];
    maxx = max(maxx, poz[y]);
    minx = min(minx, poz[y]);
    dfs(y);
  }
}
int main() {
  scanf("%lld %lld", &n, &m);
  for (long long i = 1; i <= m; i++) {
    scanf("%lld %lld %lld", &a[i].l, &a[i].r, &a[i].d);
    v[a[i].l].push_back({a[i].r, a[i].d});
  }
  for (int i = 1; i <= m; i++) {
    int p = a[i].l;
    minx = maxx = 0;
    if (!obidjen[p]) poz[p] = 0, dfs(p);
    if (maxx - minx > 1e9) {
      cout << "No" << endl;
      return 0;
    }
  }
  for (int i = 1; i <= m; i++) {
    int r = a[i].r;
    int l = a[i].l;
    int d = a[i].d;
    if (poz[r] - poz[l] != d) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
