#include <bits/stdc++.h>
using namespace std;
int in() {
  int x;
  scanf("%d", &x);
  return x;
}
template <typename T>
void pv(T a, T b) {
  for (T i = a; i < b; i++) cout << *i << ' ';
  cout << endl;
}
template <typename T, typename U>
void chmin(T &x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
void chmax(T &x, U y) {
  if (x < y) x = y;
}
vector<pair<int, int>> edges[200010];
bool visited[100010];
int calc(int s, int g, int c) {
  visited[s] = true;
  if (s == g) return c;
  for (int(i) = 0; (i) < (int)(edges[s].size()); (i)++) {
    int to = edges[s][i].first;
    int cost = edges[s][i].second;
    if (!visited[to]) {
      return calc(to, g, c + cost);
    }
  }
  return -1;
}
int main() {
  int N = in(), M = in();
  for (int(x) = 0; (x) < (int)(M); (x)++) {
    int l = in(), r = in(), d = in();
    for (int(i) = 0; (i) < (int)(100010); (i)++) visited[i] = false;
    int cost = calc(l, r, 0);
    if (cost != d && cost != -1) {
      cout << "No" << endl;
      return 0;
    }
    edges[l].push_back(make_pair(r, d));
    edges[r].push_back(make_pair(l, d));
  }
  cout << "Yes" << endl;
  return 0;
}
