#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
void search(int pos, bool *done, bool *edge_done, queue<int> &que,
            vector<pair<int, int>> *vec) {
  pair<int, int> p;
  while (!vec[pos].empty()) {
    p = vec[pos].back();
    vec[pos].pop_back();
    if (edge_done[p.second])
      continue;
    else {
      que.push(p.second);
      edge_done[p.second] = true;
      search(p.first, done, edge_done, que, vec);
    }
  }
  done[pos] = true;
}
int main() {
  int N, M;
  int L[200000], R[200000], D[200000];
  cin >> N >> M;
  for (int i = 0; i < M; i++) cin >> L[i] >> R[i] >> D[i];
  vector<pair<int, int>> vec[100000];
  for (int i = 0; i < M; i++) {
    vec[L[i]].push_back(make_pair(R[i], i));
    vec[R[i]].push_back(make_pair(L[i], i));
  }
  queue<int> que;
  bool done[100000];
  bool edge_done[200000];
  for (int i = 0; i < N; i++) {
    if (done[i]) continue;
    search(i, done, edge_done, que, vec);
  }
  bool fix[100000];
  long long pos[100000];
  int num;
  while (!que.empty()) {
    num = que.front();
    que.pop();
    if (!fix[L[num]] && !fix[R[num]]) {
      pos[L[num]] = 0;
      pos[R[num]] = D[num];
      fix[L[num]] = true;
      fix[R[num]] = true;
    } else if (!fix[L[num]]) {
      pos[L[num]] = pos[R[num]] - D[num];
      fix[L[num]] = true;
    } else if (!fix[R[num]]) {
      pos[R[num]] = pos[L[num]] + D[num];
      fix[R[num]] = true;
    } else {
      if ((pos[R[num]] - pos[L[num]]) != D[num]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
  return 0;
}
