#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000;
const long long int INF = 9000000000000000000;
const double EPS = 10e-9;
long long int pos[100001];
vector<pair<int, long long int> > link[100001];
int n, m;
bool dfs(int v) {
  for (int i = 0; i < link[v].size(); i++) {
    int nv = link[v][i].first;
    long long int dis = link[v][i].second;
    if (pos[nv] == INF) {
      pos[nv] = dis + pos[v];
      return dfs(nv);
    } else {
      if (pos[nv] - pos[v] != dis) return false;
    }
  }
  return true;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) pos[i] = INF;
  for (int i = 0; i < m; i++) {
    int a, b;
    long long int d;
    cin >> a >> b >> d;
    a--, b--;
    link[a].push_back(pair<int, long long int>(b, d));
    link[b].push_back(pair<int, long long int>(a, -d));
  }
  for (int i = 0; i < n; i++) {
    if (pos[i] == INF) {
      pos[i] = 0;
      if (!dfs(i)) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
