#include <bits/stdc++.h>
const double eps = (1e-10);
using namespace std;
int dcmp(double a, double b) {
  return fabs(a - b) <= eps ? 0 : (a > b) ? 1 : -1;
}
long long getBit(long long num, int idx) { return ((num >> idx) & 1ll) == 1ll; }
long long setBit1(long long num, int idx) { return num | (1ll << idx); }
long long setBit0(long long num, int idx) { return num & ~(1ll << idx); }
long long flipBit(long long num, int idx) { return num ^ (1ll << idx); }
int countNumBit1(long long mask) {
  int ret = 0;
  while (mask) {
    mask &= (mask - 1ll);
    ++ret;
  }
  return ret;
}
const long long oo = 100000000000000;
vector<pair<pair<int, int>, int> > v;
long long arr[1000000];
int main() {
  int n, m;
  cin >> n >> m;
  int a, b, d;
  for (int i = 0; i < m; i++) {
    cin >> a >> b >> d;
    v.push_back(make_pair(make_pair(a, b), d));
  }
  for (int i = 0; i < 1000000; i++) arr[i] = -oo;
  sort(((v).begin()), ((v).end()));
  int fl = 0;
  for (int i = 0; i < ((int)(v).size()); i++) {
    long long a = v[i].first.first;
    long long b = v[i].first.second;
    long long d = v[i].second;
    if (arr[a] == -oo && arr[b] == -oo) {
      arr[a] = 0;
      arr[b] = arr[a] + d;
    } else if (arr[a] != -oo && arr[b] == -oo) {
      arr[b] = arr[a] + d;
    } else if (arr[a] != -oo && arr[b] != -oo) {
      long long dist = arr[b] - arr[a];
      if (dist != d) {
        fl = 1;
        break;
      }
    } else if (arr[a] == -oo && arr[b] != -oo) {
      arr[a] = arr[b] - d;
    }
  }
  if (!fl)
    cout << "Yes\n";
  else
    cout << "No\n";
}
