#include <bits/stdc++.h>
using namespace std;
const int N = 100050;
vector<pair<int, long long>> v[N];
set<int> ans[N];
long long D[N];
int n, m;
int dfs(int s, int dist) {
  if (D[s] != (1LL << 40)) {
    return (D[s] == dist) ? 1 : 0;
  }
  D[s] = dist;
  int ret = 1;
  for (auto it : v[s]) {
    int x = dfs(it.first, dist + it.second);
    ret = min(ret, x);
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m;
  long long l, r, d;
  for (int i = 0; i < m; i++) {
    cin >> l >> r >> d;
    if (l > r) swap(l, r);
    v[l].push_back(make_pair(r, d));
    v[r].push_back(make_pair(l, -d));
  }
  bool vis[n];
  memset(vis, false, sizeof vis);
  for (int i = 0; i < N; i++) {
    D[i] = 1LL << 40;
  }
  bool ans = true;
  for (int i = 1; i <= n; i++) {
    if (D[i] == (1LL << 40) && dfs(i, 0) == 0) {
      ans = false;
      break;
    }
  }
  cout << (ans ? "Yes" : "No") << (char)0x0A;
}
