#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
inline void Max(T &a, U b) {
  if (a < b) a = b;
}
template <class T, class U>
inline void Min(T &a, U b) {
  if (a > b) a = b;
}
long long dp[100005];
int n, m, l, r, d;
int root[100005];
vector<pair<int, int> > G[100005];
int root_(int a) {
  if (root[a] != a) return root_(root[a]);
  return a;
}
void union_(int x, int y) {
  int xroot = root_(x);
  int yroot = root_(y);
  if (xroot < yroot)
    root[y] = xroot;
  else if (xroot > yroot)
    root[x] = yroot;
}
bool dfs(int u, int p, int dis) {
  if (dp[u] == 1000000007) dp[u] = dp[p] + dis;
  if (dp[u] != dp[p] + dis) return false;
  for (auto &e : G[u]) {
    if (e.first == p) continue;
    if (!dfs(e.first, u, e.second)) return false;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) root[i] = i;
  for (int i = 0; i < m; i++) {
    cin >> l >> r >> d;
    if (l < r)
      G[l].emplace_back(r, d);
    else
      G[r].emplace_back(l, -d);
  }
  for (int i = 1; i <= n; ++i) {
    for (auto &e : G[i]) {
      int x = root_(i);
      int y = root_(e.first);
      union_(x, y);
    }
  }
  for (int i = 1; i <= n; ++i) dp[i] = 1000000007;
  for (int i = 1; i <= n; ++i) {
    if (root_(i) == i) {
      if (!dfs(i, 0, 0)) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}
