#include <bits/stdc++.h>
using namespace std;
const int N = 100001;
vector<pair<int, int> > g[N];
int tin[N], tout[N];
int D[N];
int _tm;
bool vis[N];
bool dfs(int c, int d) {
  D[c] = d;
  tin[c] = ++_tm;
  bool res = true;
  for (int i = 0; i < g[c].size(); i++) {
    int u = g[c][i].first;
    if (vis[u]) {
      if (tin[c] >= tin[u] && tin[c] <= tout[u]) return false;
      if (D[u] - D[c] != g[c][i].second) return false;
    } else {
      vis[u] = true;
      res &= dfs(u, d + g[c][i].second);
    }
  }
  tout[c] = ++_tm;
  return res;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, v, d;
    scanf("%d%d%d", &u, &v, &d);
    g[u].push_back(make_pair(v, d));
  }
  bool res = true;
  for (int i = 1; i < n + 1; i++)
    if (!vis[i]) {
      vis[i] = true;
      res &= dfs(i, 0);
    }
  if (res)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}
