#include <bits/stdc++.h>
using namespace std;
typedef struct E {
  int to, cost;
} edge;
vector<vector<edge> > E(100010);
int n, m;
bool used[100010] = {};
long long human[100010] = {};
bool flag = true;
void dfs(int now, int dis) {
  for (int i = 0; i < E[now].size(); i++) {
    if (!used[E[now][i].to]) {
      used[E[now][i].to] = true;
      human[E[now][i].to] = dis + E[now][i].cost;
      dfs(E[now][i].to, dis + E[now][i].cost);
    } else {
      if (abs(human[now] - human[E[now][i].to]) != E[now][i].cost) flag = false;
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    edge e;
    e.to = r;
    e.cost = d;
    E[l].push_back(e);
    e.to = l;
    e.cost = -d;
    E[r].push_back(e);
  }
  for (int i = 1; i <= n; i++) {
    if (used[i] == false) dfs(i, human[i]);
  }
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
