#include <bits/stdc++.h>
using namespace std;
const int N = 200200;
const int mod = 1e9 + 7;
int n, m, u, v, cost;
int in[N], out[N];
vector<int> g[N], gr[N], er[N], e[N];
vector<int> order;
int d[N];
int used[N];
int q[N];
inline void dfs(int v, int p = -1) {
  used[v] = 1;
  for (int to : g[v]) {
    if (to == p) continue;
    if (used[to] == 1) {
      cout << "No";
      exit(0);
    }
    if (!used[to]) dfs(to, v);
  }
  used[v] = 2;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d%d", &u, &v, &cost);
    g[u].push_back(v);
    e[u].push_back(cost);
    gr[v].push_back(u);
    er[v].push_back(cost);
    out[u]++;
    in[v]++;
  }
  for (int i = 1; i <= n; ++i)
    if (!used[i]) dfs(i);
  for (int i = 1; i <= n; ++i) d[i] = -1;
  int qs = 0, qt = 0;
  for (int i = 1; i <= n; ++i)
    if (in[i] != 0 && out[i] != 0) q[qt++] = i, d[i] = 0;
  while (qs < qt) {
    int v = q[qs++];
    for (int i = 0; i < g[v].size(); ++i) {
      int to = g[v][i], cost = e[v][i];
      if (d[to] == -1)
        d[to] = d[v] + cost, q[qt++] = to;
      else if (d[to] != d[v] + cost)
        return cout << "No", 0;
    }
    for (int i = 0; i < gr[v].size(); ++i) {
      int to = gr[v][i], cost = er[v][i];
      if (d[to] == -1)
        d[to] = d[v] - cost, q[qt++] = to;
      else if (d[to] != d[v] - cost)
        return cout << "No", 0;
    }
  }
  cout << "Yes";
  return 0;
}
