#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<int> pos(n, INT_MAX);
  vector<map<int, int> > g(n);
  bool check = true;
  for (int i = 0; i < m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    if (g[l].find(r) != g[l].end() and g[l][r] != d) check = false;
    g[l][r] = d;
    if (g[r].find(l) != g[l].end() and g[r][l] != -d) check = false;
    g[r][l] = -d;
  }
  if (!check) {
    cout << "No\n";
    return 0;
  }
  vector<bool> vst(n, false);
  for (int i = 0; i < n; i++) {
    if (!vst[i]) {
      vst[i] = true;
      pos[i] = 0;
      stack<int> dfs;
      dfs.push(i);
      while (!dfs.empty()) {
        int y = dfs.top();
        dfs.pop();
        for (auto x : g[y]) {
          if (!vst[x.first]) {
            vst[x.first] = true;
            pos[x.first] = pos[y] + x.second;
            dfs.push(x.first);
          }
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (auto x : g[i])
      if (pos[x.first] != pos[i] + x.second) check = false;
  }
  if (!check)
    cout << "No\n";
  else
    cout << "Yes\n";
  return 0;
}
