#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, inf = -1000000000;
  scanf("%d %d", &n, &m);
  vector<vector<pair<int, int>>> a(n, vector<pair<int, int>>(0));
  for (int i = 0, j, k, l; i < m; ++i) {
    scanf("%d %d %d", &j, &k, &l);
    a[--j].push_back(make_pair(l, --k));
    a[k].push_back(make_pair(-l, j));
  }
  vector<int> cost(n, inf);
  for (int i = 0; i < n; ++i) {
    if (cost[i] == inf && a[i].size()) {
      cost[i] = 0;
    }
    for (int j = 0; j < a[i].size(); ++j) {
      if (cost[a[i][j].second] == inf) {
        cost[a[i][j].second] = cost[i] + a[i][j].first;
      } else {
        if (cost[a[i][j].second] != cost[i] + a[i][j].first) {
          printf("No\n");
          return 0;
        }
      }
    }
  }
  printf("Yes\n");
  return 0;
}
