#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) {
  long long g = gcd(a, b);
  return a / g * b;
}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = (int)1e9;
const long long inf = (long long)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
struct UnionFind {
  std::vector<int> par;
  std::vector<int> rank;
  std::vector<int> diff_weight;
  UnionFind(int N, int W = 0) : par(N), diff_weight(N) {
    for (int i = 0; i < N; i++) {
      par[i] = i;
      rank[i] = 0;
      diff_weight[i] = W;
    }
  }
  int root(int x) {
    if (par[x] == x) return x;
    diff_weight[x] += diff_weight[par[x]];
    return par[x] = root(par[x]);
  }
  int weight(int x) {
    root(x);
    return diff_weight[x];
  }
  int diff(int x, int y) { return weight(y) - weight(x); }
  void unite(int x, int y, int w) {
    w += weight(x);
    w -= weight(y);
    x = root(x);
    y = root(y);
    if (x != y) {
      if (rank[x] < rank[y]) {
        std::swap(x, y);
        w = -w;
      } else if (rank[x] == rank[y]) {
        ++rank[x];
      }
      par[y] = x;
      diff_weight[y] = w;
    }
  }
  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  for (long long i = 0; i < m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    if (uf.same(l, r)) {
      int diff = uf.diff(l, r);
      if (diff != d) {
        std::cout << "No" << '\n';
        return 0;
      }
    } else {
      uf.unite(l, r, d);
    }
  }
  std::cout << "Yes" << '\n';
  return 0;
}
