#include <bits/stdc++.h>
using namespace std;
int const M = 2e5 + 10, inf = 1e9 + 10, mod = 1e9 + 7, M2 = 1e6 + 10,
          M3 = 3e3 + 10;
int l[M], r[M], q[M], d[M];
vector<int> adj[M], edg[M], adj2[M], edg2[M];
bool mark[M];
int cur[M];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++)
    scanf("%d%d%d", &l[i], &r[i], &d[i]), adj[l[i]].push_back(r[i]),
        adj2[r[i]].push_back(l[i]), edg[l[i]].push_back(d[i]),
        edg2[r[i]].push_back(d[i]);
  int tail = 0, head = 0;
  int cnt = 0;
  while (true) {
    int head = 0, tail = 0;
    for (int i = 1; i <= n; i++) {
      if (!mark[i]) {
        q[head++] = i;
        mark[i] = 1;
        break;
      }
    }
    if (head == 0) return cout << "Yes", 0;
    while (head > tail) {
      int now = q[tail++];
      for (int j = 0; j < adj[now].size(); j++) {
        int u = adj[now][j];
        if (mark[u] && cur[u] != cur[now] + edg[now][j]) return cout << "No", 0;
        if (mark[u]) continue;
        cur[u] = cur[now] + edg[now][j];
        q[head++] = u;
        mark[u] = 1;
      }
      for (int j = 0; j < adj2[now].size(); j++) {
        int u = adj2[now][j];
        if (mark[u] && cur[u] != cur[now] - edg2[now][j])
          return cout << "No", 0;
        if (mark[u]) continue;
        cur[u] = cur[now] - edg2[now][j];
        q[head++] = u;
        mark[u] = 1;
      }
    }
  }
}
