#include <bits/stdc++.h>
using namespace std;
int n, m;
bool fl;
int l[100001], r[1000001];
long long d[100001];
vector<pair<int, long long> > G[100001];
vector<pair<int, long long> > rG[100001];
bool flag[100001];
long long dist[100001];
void dfs(int v, int p, long long c) {
  flag[v] = true;
  dist[v] = c;
  for (int i = 0; i < G[v].size(); i++) {
    int nv = G[v][i].first;
    long long nc = G[v][i].second;
    if (nv == p) continue;
    if (flag[nv]) {
      if (dist[nv] != dist[v] + nc) fl = false;
    } else {
      dfs(nv, v, c + nc);
    }
  }
  for (int i = 0; i < rG[v].size(); i++) {
    int nv = rG[v][i].first;
    long long nc = rG[v][i].second;
    if (nv == p) continue;
    if (flag[nv]) {
      if (dist[nv] != dist[v] + nc) fl = false;
    } else {
      dfs(nv, v, c + nc);
    }
  }
}
int main(void) {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d%lld", &l[i], &r[i], &d[i]);
    l[i]--;
    r[i]--;
    G[l[i]].push_back(pair<int, long long>(r[i], d[i]));
    rG[r[i]].push_back(pair<int, long long>(l[i], -d[i]));
  }
  fl = true;
  for (int i = 0; i < n; i++) {
    if (!flag[i]) {
      dfs(i, -1, 0);
    }
  }
  printf("%s\n", fl ? "Yes" : "No");
  return 0;
}
