#include <bits/stdc++.h>
using namespace std;
class UnionFind {
  int n;
  vector<int> data;

 public:
  UnionFind(int _n) : n(_n), data(_n, -1) {}
  bool link(int a, int b) {
    int ra = find_root(a);
    int rb = find_root(b);
    if (ra != rb) {
      if (data[rb] < data[ra]) swap(ra, rb);
      data[ra] += data[rb];
      data[rb] = ra;
    }
    return (ra != rb);
  }
  bool check(int a, int b) { return (find_root(a) == find_root(b)); }
  int find_root(int a) {
    return ((data[a] < 0) ? a : (data[a] = find_root(data[a])));
  }
};
int N, M;
int L[100005], R[100005], D[100005];
vector<pair<int, long long>> G[100005];
bool check(const vector<int>& v) {
  if (v.size() == 1) return true;
  map<int, int> memo;
  for (int i = (0); i < (int)(v.size()); i++) {
    memo[v[i]] = 0;
  }
  map<int, long long> pos;
  map<int, int> checked;
  queue<int> que;
  que.push(v[0]);
  pos[v[0]] = 0;
  memo[v[0]] = 1;
  while (!que.empty()) {
    int p = que.front();
    que.pop();
    if (checked[p] > 0) continue;
    checked[p]++;
    for (int i = (0); i < (int)(G[p].size()); i++) {
      int q = G[p][i].first;
      long long dist = G[p][i].second;
      if (pos.count(q) > 0) {
        if (pos[p] + dist != pos[q]) return false;
      } else {
        pos[q] = pos[p] + dist;
        memo[q] = 1;
        que.push(q);
      }
    }
  }
  for (__typeof((memo).begin()) it = (memo).begin(); it != (memo).end(); ++it) {
    if (it->second == 0) return false;
  }
  return true;
}
int main() {
  cin >> N >> M;
  UnionFind uf(N + 1);
  for (int i = (0); i < (int)(M); i++) {
    cin >> L[i] >> R[i] >> D[i];
    G[L[i]].push_back(make_pair(R[i], D[i]));
    G[R[i]].push_back(make_pair(L[i], -D[i]));
    uf.link(L[i], R[i]);
  }
  map<int, vector<int>> memo;
  for (int i = (1); i < (int)(N + 1); i++) {
    memo[uf.find_root(i)].push_back(i);
  }
  for (__typeof((memo).begin()) it = (memo).begin(); it != (memo).end(); ++it) {
    if (!check(it->second)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
