#include <bits/stdc++.h>
using namespace std;
int d[100100];
vector<pair<int, int> > aList[100100];
int N, M, a, b, c;
void dfs(int x) {
  for (auto i : aList[x]) {
    int nxt = 0;
    if (i.first < x)
      nxt = d[x] - i.second;
    else
      nxt = d[x] + i.second;
    if (d[i.first] == -1) {
      d[i.first] = nxt;
      dfs(i.first);
    } else {
      if (nxt != d[i.first]) {
        cout << "No";
        exit(0);
      }
    }
  }
}
int main() {
  cin >> N >> M;
  for (int i = 0; i < M; ++i) {
    cin >> a >> b >> c;
    aList[a].push_back(make_pair(b, c));
    aList[b].push_back(make_pair(a, c));
  }
  memset(d, -1, sizeof(d));
  for (int i = 1; i <= N; ++i) {
    if (d[i] != -1) continue;
    d[i] = d[i - 1] + 1;
    dfs(i);
  }
  for (int i = 1; i < N; ++i) {
    if (d[i] > d[i + 1]) {
      cout << "No";
      exit(0);
    }
  }
  cout << "Yes";
}
