#include <bits/stdc++.h>
using namespace std;
bool pos = 1;
int N, M, A, B, C, d[100005];
struct edge {
  int x, y, c;
} v[100005 * 2];
bool cond(edge a, edge b) { return a.x < b.x || (a.x == b.x && a.y < b.y); }
int main() {
  cin >> N >> M;
  for (int i = 1; i <= M; i++) {
    cin >> v[i].x >> v[i].y >> v[i].c;
    if (v[i].x > v[i].y) swap(v[i].x, v[i].y);
  }
  sort(v + 1, v + 1 + M, cond);
  for (int i = 2; i <= N; i++) d[i] = 2140000000;
  d[1] = 0;
  for (int i = 1; i <= M; i++) {
    if (d[v[i].y] == 2140000000)
      d[v[i].y] = d[v[i].x] + v[i].c;
    else {
      if (d[v[i].y] != d[v[i].x] + v[i].c) {
        cout << "No";
        return 0;
      }
    }
  }
  cout << "Yes";
  return 0;
}
