#include <bits/stdc++.h>
using namespace std;
const long long INF = 1l << 60;
struct Graph {
  long long V, E;
  static const long long MAX_V = 100100;
  vector<pair<long long, long long> > G[MAX_V];
  long long x[MAX_V];
  bool left[MAX_V];
  bool used[MAX_V];
  Graph(long long V, long long E) : V(V), E(E) {
    for (long long i = 0; i < (MAX_V); ++i) {
      x[i] = -1;
      left[i] = true;
      used[i] = false;
    }
  }
  Graph() {}
  void init(long long v, long long e) {
    V = v, E = e;
    for (long long i = 0; i < (MAX_V); ++i) {
      x[i] = -1;
      left[i] = true;
      used[i] = false;
    }
  }
  void addEdge(long long a, long long b, long long c) {
    G[a].emplace_back(b, c);
    left[b] = false;
  }
  bool check(long long v, long long prev, long long d) {
    if (used[v]) return true;
    used[v] = true;
    if (x[v] == -1) {
      x[v] = x[prev] + d;
      for (long long i = 0; i < (G[v].size()); ++i) {
        long long to = G[v][i].first;
        long long d2 = G[v][i].second;
        if (!check(to, v, d2)) return false;
      }
      return true;
    } else {
      if (x[v] != x[prev] + d) return false;
      for (long long i = 0; i < (G[v].size()); ++i) {
        long long to = G[v][i].first;
        long long d2 = G[v][i].second;
        if (!check(to, v, d2)) return false;
      }
      return true;
    }
  }
  bool check(long long v) {
    if (!left[v]) return true;
    if (used[v]) return true;
    used[v] = true;
    x[v] = 5000000000000000000;
    for (long long i = 0; i < (G[v].size()); ++i) {
      long long to = G[v][i].first;
      long long d = G[v][i].second;
      if (!check(to, v, d)) return false;
    }
    return true;
  }
  bool hasLoop() {
    for (long long i = 0; i < (V); ++i) {
      if (!used[i]) return true;
    }
    return false;
  }
};
Graph g;
signed main() {
  long long N, M;
  cin >> N >> M;
  g.init(N, M);
  for (long long i = 0; i < (M); ++i) {
    long long l, r, d;
    cin >> l >> r >> d;
    --l, --r;
    g.addEdge(l, r, d);
  }
  for (long long i = 0; i < (N); ++i) {
    if (!g.check(i)) {
      cout << "No" << endl;
      return 0;
    }
  }
  if (g.hasLoop())
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}
