#include <bits/stdc++.h>
using namespace std;
int n;
int m;
vector<pair<int, long long int> > v[100002];
long long int cur[100002];
bool vis[100002];
queue<int> q;
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int l, r, d;
    scanf("%d%d%d", &l, &r, &d);
    l--;
    r--;
    v[l].push_back(make_pair(r, d));
    v[r].push_back(make_pair(l, -d));
  }
  memset(vis, false, sizeof(vis));
  for (int i = 0; i < n; i++) {
    if (vis[i] == false) {
      q.push(i);
      cur[i] = 0;
      vis[i] = true;
      while (!q.empty()) {
        int b = q.front();
        q.pop();
        vis[b] = true;
        for (auto go : v[b]) {
          int node = go.first;
          long long int nex = cur[b] + go.second;
          if (vis[node]) {
            if (cur[node] == nex) {
              continue;
            }
            puts("No");
            exit(0);
          } else {
            cur[node] = nex;
            q.push(node);
          }
        }
      }
    }
  }
  puts("Yes");
  return 0;
}
