#include <bits/stdc++.h>
using namespace std;
typedef struct E {
  int to, cost;
} edge;
bool flag = true;
const int MAX_V = 200100;
const int Inf = 1e9;
vector<vector<edge> > E(MAX_V);
bool flag2 = false;
bool st[100010] = {};
void dfs(int l, int r, int cnt, int d) {
  if (flag2) return;
  if (l == r) {
    if (cnt != d) {
      flag = false;
    }
    flag2 = true;
    return;
  }
  for (int i = 0; i < E[l].size(); i++) {
    if (!st[E[l][i].to]) dfs(E[l][i].to, r, E[l][i].cost + cnt, d);
    st[E[l][i].to] = true;
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  long long human[n + 10];
  for (int i = 0; i < n + 10; i++) human[i] = -2147483647;
  for (int i = 0; i < m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    if (!flag) continue;
    edge e;
    e.to = r;
    e.cost = d;
    E[l].push_back(e);
    if (human[l] == -1 || human[r] == -1) {
      human[l] = human[r] = 1;
    } else {
      fill_n(st, 100010, false);
      flag2 = false;
      dfs(l, r, 0, d);
    }
  }
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
