#include <bits/stdc++.h>
using namespace std;
int N, M;
int v[200005], f[200005];
vector<pair<int, int> > edg[200005];
queue<int> q;
void answer(bool ok) {
  if (ok)
    printf("Yes\n");
  else
    printf("No\n");
  exit(0);
}
int main() {
  scanf("%d%d", &N, &M);
  for (int i = 1; i <= M; i++) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    edg[x].push_back({y, -z});
    edg[y].push_back({x, z});
  }
  v[1] = 0;
  f[1] = 1;
  q.push(1);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (auto e : edg[x]) {
      int nxt = e.first;
      int d = e.second;
      if (f[nxt]) {
        bool ok = (d == v[x] - v[nxt]);
        if (!ok) answer(0);
        continue;
      }
      v[nxt] = v[x] - d;
      f[nxt] = 1;
      q.push(nxt);
    }
  }
  answer(1);
  return 0;
}
