#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using ld = long double;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const lint INF = 10000000000000000;
const int mod = 1000000007;
int n, m;
struct Edge {
  int to;
  int cost;
};
vector<pair<int, int>> r;
vector<int> d;
vector<vector<Edge>> c;
void dfs(int a, vector<int> &ans) {
  for (int i = 0; i < c[a].size(); i++) {
    if (ans[c[a][i].to] != mod) continue;
    ans[c[a][i].to] = ans[a] + -c[a][i].cost;
    dfs(i, ans);
  }
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m;
  r.resize(m);
  d.resize(m);
  c.resize(n);
  for (int i = 0; i < m; i++) {
    cin >> r[i].first >> r[i].second >> d[i];
    r[i].first--;
    r[i].second--;
    c[r[i].first].push_back({r[i].second, d[i]});
    c[r[i].second].push_back({r[i].first, -d[i]});
  }
  vector<int> ans(n, mod);
  for (int j = 0; j < n; j++) {
    if (ans[j] == mod) ans[j] = 0;
    dfs(j, ans);
  }
  bool h = true;
  for (int i = 0; i < m; i++) {
    if (ans[r[i].first] - ans[r[i].second] != d[i]) h = false;
  }
  if (h)
    puts("Yes");
  else
    puts("No");
  return 0;
}
