#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000000000000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
                         {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};
int main() {
  static long long n, m;
  static long long l[200010], r[100010], d[100010];
  scanf("%lld%lld", &n, &m);
  for (int i = 0; i < m; i++) scanf("%lld%lld%lld", &l[i], &r[i], &d[i]);
  static vector<pair<long long, long long> > G[100010];
  for (int i = 0; i < m; i++) {
    G[l[i]].push_back(pair<long long, long long>(r[i], d[i]));
    G[r[i]].push_back(pair<long long, long long>(l[i], -d[i]));
  }
  static long long x[100010];
  for (int i = 0; i < 100010; i++) x[i] = -INF;
  for (int i = 1; i <= n; i++) {
    if (x[l[i]] != -INF) continue;
    x[l[i]] = 0;
    queue<int> que;
    que.push(l[i]);
    while (!que.empty()) {
      int q = que.front();
      que.pop();
      for (int j = 0; j < G[q].size(); j++) {
        if (x[G[q][j].first] != -INF) continue;
        x[G[q][j].first] = x[q] + G[q][j].second;
        que.push(G[q][j].first);
      }
    }
  }
  for (int i = 0; i < m; i++) {
    if (x[l[i]] + d[i] != x[r[i]]) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
}
