#include <bits/stdc++.h>
using namespace std;
int p[110000];
vector<pair<int, int> > e[110000];
int xx[110000];
int da, db;
bool v;
void init(void) {
  v = true;
  for (int i = 0; i < int(110000); i++) {
    p[i] = i;
    xx[i] = -1;
  }
  v = true;
  return;
}
int par(int x, int y) {
  if (p[x] == x)
    return x;
  else {
    if (y == 0)
      da++;
    else
      db++;
    return p[x] = par(p[x], y);
  }
  return 0;
}
void uni(int x, int y) {
  da = 0;
  db = 0;
  x = par(x, 0);
  y = par(y, 1);
  if (da > db)
    p[y] = x;
  else
    p[x] = y;
  return;
}
void dfs(int x) {
  for (int i = 0; i < e[x].size(); i++) {
    if (xx[e[x][i].first] == -1) {
      xx[e[x][i].first] = xx[x] + e[x][i].second;
      dfs(e[x][i].first);
      if (v == false) break;
    } else {
      if (xx[e[x][i].first] != xx[x] + e[x][i].second) {
        v = false;
        break;
      }
    }
  }
  return;
}
int main() {
  int a[110000];
  for (int i = 0; i < int(110000); i++) a[i] = 0;
  int x, y, z;
  int n, k, m;
  long long s, ans;
  ans = 0;
  init();
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d %d %d", &x, &y, &z);
    x--;
    y--;
    e[x].push_back(make_pair(y, z));
    e[y].push_back(make_pair(x, -z));
    uni(x, y);
  }
  for (int i = 0; i < n; i++) {
    da = 0;
    p[i] = par(i, 0);
  }
  for (int i = 0; i < n; i++) {
    if (p[i] == i) {
      xx[i] = 0;
      dfs(i);
      if (v == false) break;
    }
  }
  if (v)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}
