#include <bits/stdc++.h>
using namespace std;
int N, M;
int L[100005], R[100005], D[100005];
vector<pair<int, long long>> G[100005];
long long pos[100005];
void dfs(int p) {
  for (int i = (0); i < (int)(G[p].size()); i++) {
    int q = G[p][i].first;
    long long dist = G[p][i].second;
    if (pos[q] == -1000000000000000000LL) {
      pos[q] = pos[p] + dist;
      dfs(q);
    }
  }
}
int main() {
  cin >> N >> M;
  for (int i = (0); i < (int)(100005); i++) {
    pos[i + 1] = -1000000000000000000LL;
  }
  for (int i = (0); i < (int)(M); i++) {
    cin >> L[i] >> R[i] >> D[i];
    G[L[i]].push_back(make_pair(R[i], D[i]));
    G[R[i]].push_back(make_pair(L[i], -D[i]));
  }
  for (int i = (0); i < (int)(N); i++) {
    int p = i + 1;
    if (pos[p] == -1000000000000000000LL) {
      pos[p] = 0;
      dfs(p);
    }
  }
  long long mn = 1000000000000000000LL, mx = -1000000000000000000LL;
  for (int i = (0); i < (int)(N); i++) {
    mn = min(mn, pos[i + 1]);
  }
  for (int i = (0); i < (int)(N); i++) {
    pos[i + 1] += mn;
    mx = max(mx, pos[i + 1]);
  }
  if (mx > 1000000000) {
    cout << "No" << endl;
    return 0;
  }
  for (int i = (0); i < (int)(M); i++) {
    if (pos[L[i]] + D[i] != pos[R[i]]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
