#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int n, m;
struct Edge {
  int l, r, d;
  Edge(int a = 0, int b = 0, int c = 0) : l(a), r(b), d(c) {}
};
vector<Edge> v[maxn * 2];
int nod[maxn * 2], vis[maxn * 2], p[maxn * 2];
bool ok;
int dfs(int x, int k, int d) {
  int id = lower_bound(nod, nod + k, x) - nod;
  if (k && nod[id] == x) {
    ok = false;
    return 0;
  }
  if (vis[x]) return p[x];
  vis[x] = 1;
  if (v[x].size() == 0) return p[x] = d;
  bool has_exit = false;
  nod[k] = x;
  for (int i = 0; i < v[x].size() && ok; i++) {
    int nxt = d;
    if (has_exit) nxt = p[x];
    int pos = dfs(v[x][i].r, k + 1, nxt + v[x][i].d);
    if (!has_exit) {
      has_exit = true;
      p[x] = pos - v[x][i].d;
    } else if (pos - v[x][i].d != p[x])
      ok = false;
  }
  cout << x << " " << p[x] << endl;
  return p[x];
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    v[a].push_back(Edge{a, b, c});
  }
  ok = true;
  for (int i = 1; i <= n && ok; i++) {
    if (vis[i]) continue;
    dfs(i, 0, 0);
  }
  puts(ok ? "Yes" : "No");
  return 0;
}
