#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10, INF = 1000000009, MOD = 1e9 + 7;
const int Move[4][2] = {-1, 0, 1, 0, 0, 1, 0, -1};
const int Move_[8][2] = {-1, -1, -1, 0, -1, 1, 0, -1, 0, 1, 1, -1, 1, 0, 1, 1};
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
void init() {}
vector<pair<int, int> > E[maxn];
long long d[maxn];
int main() {
  ios_base::sync_with_stdio(0);
  init();
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    E[r].push_back(make_pair(l, -d));
    E[l].push_back(make_pair(r, d));
  }
  for (int i = 0; i < maxn; i++) d[i] = INF;
  for (int i = 1; i <= n; i++) {
    if (d[i] == INF) {
      queue<int> q;
      q.push(i);
      d[i] = 0;
      while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (int j = 0; j < E[u].size(); j++) {
          int v = E[u][j].first;
          int val = E[u][j].second;
          if (d[v] == INF) {
            d[v] = d[u] + (long long)val;
            q.push(v);
          } else if (d[v] - d[u] != val) {
            cout << "No" << endl;
            return 0;
          }
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
