#include <bits/stdc++.h>
using namespace std;
const int maxn = 100011;
vector<pair<int, int> > G[maxn];
bool visit[maxn];
int d[maxn];
int n, m;
bool flag;
void dfs(int s) {
  for (int i = 0; i < G[s].size(); i++) {
    if (!visit[G[s][i].first]) {
      visit[G[s][i].first] = true;
      d[G[s][i].first] = d[s] + G[s][i].second;
      dfs(G[s][i].first);
    } else {
      if (d[G[s][i].first] != d[s] + G[s][i].second) {
        flag = false;
        return;
      }
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    G[a].push_back(pair<int, int>(b, c));
    G[b].push_back(pair<int, int>(a, -c));
  }
  for (int i = 0; i <= n; i++) {
    if (!visit[i]) {
      fill(d, d + maxn, 0);
      flag = true;
      dfs(i);
      if (flag == false) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
