#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 29;
const long long longinf = 1LL << 60;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
vector<pair<int, int> > v[100001];
bool used[100001];
int d[100001];
void dfs(int x) {
  for (int i = 0; i < (int)(v[x].size()); i++) {
    if (!used[v[x][i].first]) {
      used[v[x][i].first] = true;
      d[v[x][i].first] = d[x] + v[x][i].second;
      dfs(v[x][i].first);
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  int l[m], r[m], dist[m];
  for (int i = 0; i < (int)(m); i++) {
    cin >> l[i] >> r[i] >> dist[i];
    v[l[i]].push_back(pair<int, int>(r[i], dist[i]));
    v[r[i]].push_back(pair<int, int>(l[i], -dist[i]));
  }
  for (int i = 0; i < (int)(n); i++) used[i + 1] = false;
  used[1] = true;
  dfs(1);
  bool ans = true;
  for (int i = 0; i < (int)(m); i++) {
    if (d[r[i]] - d[l[i]] != dist[i]) ans = false;
  }
  if (ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
