#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int64_t> > adj[100001];
int64_t dis[100001];
void dfs(int v, int64_t d) {
  if (dis[v]) {
    if (dis[v] != d) {
      printf("No\n");
      exit(0);
    }
    return;
  }
  dis[v] = d;
  for (int i = 0; i < adj[v].size(); i++) {
    int u = adj[v][i].first;
    int64_t w = adj[v][i].second;
    dfs(u, d + w);
  }
}
int main(void) {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int l, r, d;
    scanf("%d%d%d", &l, &r, &d);
    adj[l].push_back(make_pair(r, d));
    adj[r].push_back(make_pair(l, -d));
  }
  for (int i = 1; i <= n; i++)
    if (!dis[i]) dfs(i, -1);
  printf("Yes\n");
  return 0;
}
