#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long double eps = 1e-7;
const int inf = 1000000010;
const long long INF = 10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 100010, LOG = 20;
int n, m, k, u, v, x, y, t, a, b, ans;
int A[MAXN];
int E[MAXN][3];
int sum[MAXN];
bool mark[MAXN];
vector<pair<int, int> > G[MAXN];
void dfs(int node) {
  mark[node] = 1;
  for (pair<int, int> p : G[node])
    if (!mark[p.first]) {
      sum[p.first] = sum[node] + p.second;
      dfs(p.first);
    }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> E[i][0] >> E[i][1] >> E[i][2];
    G[E[i][0]].push_back({E[i][1], E[i][2]});
    G[E[i][1]].push_back({E[i][0], -E[i][2]});
  }
  for (int i = 1; i <= n; i++)
    if (!mark[i]) dfs(i);
  for (int i = 1; i <= m; i++) {
    if (sum[E[i][1]] - sum[E[i][0]] != E[i][2]) return cout << "No" << '\n', 0;
  }
  return cout << "Yes" << '\n', 0;
  return 0;
}
