#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 25, M = 1e6 + 25, oo = 1e9 + 7, mxmsk = 1 << 16;
const long long OO = 1e18 + 25;
int n, m, l, r, d, dis[N], vis[N];
vector<pair<int, int>> g[N];
int dfs(int from) {
  vis[from] = 1;
  for (auto pa : g[from]) {
    if (!vis[pa.first]) {
      dis[pa.first] = dis[from] + pa.second;
      if (dfs(pa.first) == -1) {
        return -1;
      }
    } else if (dis[pa.first] != dis[from] + pa.second) {
      return -1;
    }
  }
  return 1;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &l, &r, &d);
    g[l].push_back({r, d});
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      for (auto pa : g[i]) {
        if (vis[pa.first]) {
          dis[i] = dis[pa.first] - pa.second;
          break;
        }
      }
      if (dfs(i) == -1) {
        printf("No");
        return 0;
      }
    }
  }
  printf("Yes");
  return 0;
}
