#include <bits/stdc++.h>
using namespace std;
struct XX {
  int s;
  int t;
  int c;
};
class xxGreater {
 public:
  bool operator()(const XX& riLeft, const XX& riRight) const {
    if ((riLeft.t) == (riRight.t)) {
      return riLeft.s < riRight.s;
    }
    return (riLeft.t) < (riRight.t);
  }
};
struct edge {
  int to;
  long long cost;
};
vector<edge> G[100001];
long long usum[100001];
bool used[100001];
bool dfs(int s, long long sum) {
  if (used[s]) {
    if (usum[s] == sum) {
      return true;
    } else {
      return false;
    }
  } else {
    usum[s] = sum;
    used[s] = true;
  }
  for (int i = 0; i < G[s].size(); i++) {
    if (!dfs(G[s][i].to, sum + G[s][i].cost)) {
      return false;
    }
  }
  return true;
}
int main(int argc, const char* argv[]) {
  ifstream ifs("a.txt");
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  ifs >> N >> M;
  int l[200000];
  int r[200000];
  long long d[200000];
  for (int i = 0; i < M; i++) {
    ifs >> l[i] >> r[i] >> d[i];
    edge tmp;
    tmp.to = r[i];
    tmp.cost = d[i];
    G[l[i]].push_back(tmp);
    tmp.to = l[i];
    tmp.cost = -d[i];
    G[r[i]].push_back(tmp);
  }
  for (int i = 1; i <= N; i++) {
    used[i] = false;
  }
  if (!dfs(1, 0)) {
    cout << "No" << endl;
    return 0;
  }
  for (int i = 2; i <= N; i++) {
    if (used[i]) {
      continue;
    }
    if (!dfs(i, 0)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
