#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int MOD = 1000000007;
const int INF = 1000007;
const long long LINF = 1LL * INF * INF;
const int MAXN = 100007;
const double EPS = 1e-12;
bool used[MAXN], visited[MAXN];
long long X[MAXN], mn, mx;
vector<int> g[MAXN];
vector<pair<pair<int, int>, int> > Qu;
void dfs(int v) {
  visited[v] = true;
  mn = min(mn, X[v]);
  mx = max(mx, X[v]);
  for (int i = (0); i < ((int)((g[v]).size())); ++i) {
    int to = g[v][i];
    if (!visited[to]) dfs(to);
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m;
  bool ok = true;
  cin >> n >> m;
  for (int i = (0); i < (m); ++i) {
    int l, r, d;
    cin >> l >> r >> d;
    Qu.push_back(make_pair(make_pair(l, r), d));
    g[l].push_back(r);
    g[r].push_back(l);
    if (used[l])
      X[r] = X[l] + d;
    else
      X[l] = X[r] - d;
    used[l] = used[r] = true;
  }
  for (int i = (0); i < (m); ++i)
    if (X[Qu[i].first.second] - X[Qu[i].first.first] != X[Qu[i].second])
      ok = false;
  for (int i = (1); i < (n + 1); ++i) {
    if (used[i] && !visited[i]) {
      mn = LLONG_MAX;
      mx = LLONG_MIN;
      dfs(i);
      if (mx - mn > 1000000000) ok = false;
    }
  }
  cout << (ok ? "Yes" : "No");
  return 0;
}
