#include <bits/stdc++.h>
using namespace std;
struct Node {
  long long next, id, dist;
};
long long v[100001], d[100001];
bool used[100001];
Node e[1000000];
int cur = 0;
bool dfs(int root) {
  for (int next = v[root]; next != 0; next = e[next].next) {
    if (used[e[next].id]) {
      if (d[root] + e[next].dist != d[e[next].id]) {
        return false;
      }
    } else {
      d[e[next].id] = d[root] + e[next].dist;
      used[e[next].id] = true;
      if (!dfs(e[next].id)) {
        return false;
      }
    }
  }
  return true;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  memset(v, sizeof(v), 0);
  memset(used, sizeof(used), false);
  for (int i = 0; i < m; i++) {
    int x, y, dist;
    scanf("%d%d%d", &x, &y, &dist);
    cur++;
    e[cur].id = y;
    e[cur].dist = dist;
    e[cur].next = v[x];
    cur++;
    e[cur].id = x;
    e[cur].dist = -dist;
    e[cur].next = v[y];
  }
  bool ans = true;
  for (int i = 1; i <= n; i++)
    if (!used[i]) {
      used[i] = true;
      d[i] = 0;
      ans = dfs(i);
      if (!ans) {
        break;
      }
    }
  printf("%s\n", ans ? "Yes" : "No");
  return 0;
}
