#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const long long INF = 1LL << 29;
const long long mod = 1e9 + 7;
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  int n = v.size();
  for (long long(i) = 0; (i) < (long long)(n); ++(i))
    os << v[i] << (i == n - 1 ? "" : " ");
  return os;
}
vector<pair<long long, long long> > g[100010];
long long n, m, dist[100010];
bool dfs(int u) {
  for (auto &&x : g[u]) {
    int v = x.first;
    long long d = x.second;
    if (dist[v] == -1) {
      dist[v] = dist[u] + d;
      if (!dfs(v)) return false;
    } else if (dist[v] != dist[u] + d)
      return false;
  }
  return true;
}
int main() {
  cin >> n >> m;
  for (long long(i) = 0; (i) < (long long)(n); ++(i)) {
    long long l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    g[l].push_back(pair<long long, long long>(r, d));
    g[r].push_back(pair<long long, long long>(l, -d));
  }
  memset((dist), (-1), sizeof(dist));
  bool res = true;
  for (long long(i) = 0; (i) < (long long)(n); ++(i)) {
    if (dist[i] == -1) {
      dist[i] = 0;
      res &= dfs(i);
    }
  }
  cout << (res ? "Yes" : "No") << endl;
  return 0;
}
