#include <bits/stdc++.h>
using namespace std;
long long int vis[100005];
vector<pair<long long int, long long int> > lis[100005];
int yes = 1;
void serc(int x, long long int cost) {
  if (vis[x] != 0 && vis[x] != cost) {
    yes = 0;
    return;
  }
  vis[x] = cost;
  for (int i = 0; i < lis[x].size(); i++) {
    serc(lis[x][i].first, cost + lis[x][i].second);
    if (yes == 0) return;
  }
}
int main() {
  int a, b;
  long long int c;
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a >> b >> c;
    lis[a - 1].push_back(pair<long long int, long long int>(b - 1, c));
  }
  for (int i = 0; i < n; i++) {
    if (vis[i] == 0) {
      serc(i, 0);
    }
    if (yes == 0) break;
  }
  if (yes)
    printf("Yes\n");
  else
    printf("No\n");
}
