#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
const long long int INF = 1e9;
const long long int MAXN = 1e9;
vector<vector<int> > g, edge;
vector<int> dist, used;
bool flag;
void dfs(int x) {
  if (used[x]) return;
  used[x]++;
  for (auto p : g[x]) {
    if (dist[p] < 0) {
      dist[p] = dist[x] + edge[x][p];
      dfs(p);
    } else if (dist[p] - dist[x] != edge[x][p]) {
      flag = false;
      return;
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  g.resize(n, vector<int>());
  edge.resize(n, vector<int>(n, 0));
  dist.resize(n, -1);
  used.resize(n, 0);
  flag = true;
  for (int i = 0; i < m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    g[l].push_back(r);
    g[r].push_back(l);
    edge[r][l] = -d;
    edge[l][r] = d;
  }
  for (int i = 0; i < n; i++) {
    if (!flag) break;
    if (dist[i] < 0) {
      dist[i] = 0;
      dfs(i);
    }
  }
  cout << (flag ? "Yes" : "No") << endl;
  return 0;
}
