#include <bits/stdc++.h>
using namespace std;
vector<int> p[100010];
vector<int> q[100010];
int vis[100010], s[100010];
int Spfa(int x) {
  int i, j, k, t;
  queue<int> Q;
  vis[x] = 1;
  s[x] = 0;
  Q.push(x);
  while (!Q.empty()) {
    t = Q.front();
    Q.pop();
    k = p[t].size();
    for (i = 0; i < k; i++) {
      j = p[t][i];
      if (vis[j] == 0) {
        s[j] = s[t] + q[t][i];
        vis[j] = 1;
        Q.push(j);
      } else if (vis[j] == 1 && (s[j] != s[t] + q[t][i]))
        return 0;
    }
  }
  return 1;
}
int main() {
  int n, m, x, y, z, i, j, k, flag = 1;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%d%d%d", &x, &y, &z);
    p[x].push_back(y);
    p[y].push_back(x);
    q[x].push_back(z);
    q[y].push_back(-z);
  }
  for (i = 1; i <= n; i++)
    if (vis[i] == 0) {
      j = Spfa(i);
      if (j == 0) {
        printf("No\n");
        return 0;
      }
    }
  printf("Yes\n");
  return 0;
}
