#include <bits/stdc++.h>
using namespace std;
template <typename T>
void printlnVector(T v) {
  for (int i = 0; i < (int)(v.size()); i++) {
    cout << v[i] << endl;
  }
}
template <typename T>
void printVector(T v) {
  for (int i = 0; i < (int)(v.size()); i++) {
    cout << v[i] << " ";
  }
  cout << endl;
}
struct WeightedUnionFind {
  vector<pair<int, int>> d;
  WeightedUnionFind(int n = 0) : d(n, make_pair(-1, 0)) {}
  int find(int x) {
    if (d[x].first < 0) return x;
    int l = d[x].second;
    int node = d[x].first;
    int next_node = find(node);
    if (d[x].first != next_node) {
      d[x].second += l;
    }
    return next_node;
  }
  bool unite(int x, int y, int l) {
    int nx = find(x);
    int ny = find(y);
    if (nx == ny) return false;
    if (d[nx].first > d[ny].first) {
      swap(nx, ny);
      swap(x, y);
    }
    d[nx].first += d[ny].first;
    d[ny].first = nx;
    d[ny].second = d[x].second + l - d[y].second;
    nx = find(x);
    ny = find(y);
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -(d[find(x)].first); }
  int dist(int l, int r) { return d[r].second - d[l].second; }
};
int main() {
  int N, M;
  cin >> N >> M;
  WeightedUnionFind uf(N);
  bool is_ok = true;
  for (int i = 0; i < (int)(M); i++) {
    int L, R, D;
    cin >> L >> R >> D;
    if (--R < --L) D *= -1;
    if (uf.same(L, R)) {
      if (uf.dist(L, R) != D) is_ok = false;
    } else {
      uf.unite(L, R, D);
    }
    uf.same(L, R);
  }
  puts(is_ok ? "Yes" : "No");
  ;
  return 0;
}
