#include <bits/stdc++.h>
using namespace std;
const long long NMAX = 10001;
const long long INF = (1LL << 60);
const long long MOD = 998244353;
const long long BLOCK = 447;
vector<pair<long long, pair<long long, long long> > > v;
long long c[100001];
bool cmp(pair<long long, pair<long long, long long> > a,
         pair<long long, pair<long long, long long> > b) {
  long long as = min(a.first, a.second.first);
  long long bs = min(b.first, b.second.first);
  return as < bs;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n, i, j, q;
  cin >> q >> n;
  for (i = 1; i <= q; i++) {
    c[i] = (1LL << 60);
  }
  for (i = 1; i <= n; i++) {
    long long x, y, z;
    cin >> x >> y >> z;
    v.push_back({x, {y, z}});
  }
  sort(v.begin(), v.end(), cmp);
  for (auto e : v) {
    long long x = e.first, y = e.second.first, z = e.second.second;
    if (c[x] == (1LL << 60) && c[y] == (1LL << 60)) c[x] = 0;
    if (c[x] != (1LL << 60) && c[y] == (1LL << 60)) {
      c[y] = c[x] + z;
    }
    if (c[x] == (1LL << 60) && c[y] != (1LL << 60)) {
      c[x] = c[y] - z;
    }
    if (c[x] != (1LL << 60) && c[y] != (1LL << 60) && c[y] - c[x] != z) {
      cout << "No\n";
      return 0;
    }
  }
  for (auto e : v) {
    long long x = e.first, y = e.second.first, z = e.second.second;
    if (c[x] == (1LL << 60) && c[y] == (1LL << 60)) c[x] = 0;
    if (c[x] != (1LL << 60) && c[y] == (1LL << 60)) {
      c[y] = c[x] + z;
    }
    if (c[x] == (1LL << 60) && c[y] != (1LL << 60)) {
      c[x] = c[y] - z;
    }
    if (c[x] != (1LL << 60) && c[y] != (1LL << 60) && c[y] - c[x] != z) {
      cout << "No\n";
      return 0;
    }
  }
  for (auto e : v) {
    long long x = e.first, y = e.second.first, z = e.second.second;
    if (c[x] == (1LL << 60) && c[y] == (1LL << 60)) c[x] = 0;
    if (c[x] != (1LL << 60) && c[y] == (1LL << 60)) {
      c[y] = c[x] + z;
    }
    if (c[x] == (1LL << 60) && c[y] != (1LL << 60)) {
      c[x] = c[y] - z;
    }
    if (c[x] != (1LL << 60) && c[y] != (1LL << 60) && c[y] - c[x] != z) {
      cout << "No\n";
      return 0;
    }
  }
  for (auto e : v) {
    long long x = e.first, y = e.second.first, z = e.second.second;
    if (c[x] == (1LL << 60) && c[y] == (1LL << 60)) c[x] = 0;
    if (c[x] != (1LL << 60) && c[y] == (1LL << 60)) {
      c[y] = c[x] + z;
    }
    if (c[x] == (1LL << 60) && c[y] != (1LL << 60)) {
      c[x] = c[y] - z;
    }
    if (c[x] != (1LL << 60) && c[y] != (1LL << 60) && c[y] - c[x] != z) {
      cout << "No\n";
      return 0;
    }
  }
  for (auto e : v) {
    long long x = e.first, y = e.second.first, z = e.second.second;
    if (c[x] == (1LL << 60) && c[y] == (1LL << 60)) c[x] = 0;
    if (c[x] != (1LL << 60) && c[y] == (1LL << 60)) {
      c[y] = c[x] + z;
    }
    if (c[x] == (1LL << 60) && c[y] != (1LL << 60)) {
      c[x] = c[y] - z;
    }
    if (c[x] != (1LL << 60) && c[y] != (1LL << 60) && c[y] - c[x] != z) {
      cout << "No\n";
      return 0;
    }
  }
  for (auto e : v) {
    long long x = e.first, y = e.second.first, z = e.second.second;
    if (c[x] == (1LL << 60) && c[y] == (1LL << 60)) c[x] = 0;
    if (c[x] != (1LL << 60) && c[y] == (1LL << 60)) {
      c[y] = c[x] + z;
    }
    if (c[x] == (1LL << 60) && c[y] != (1LL << 60)) {
      c[x] = c[y] - z;
    }
    if (c[x] != (1LL << 60) && c[y] != (1LL << 60) && c[y] - c[x] != z) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}
