#include <bits/stdc++.h>
using namespace std;
const int mx = 1e5 + 10;
long long vis[mx];
vector<pair<int, int> > adj[mx];
int main() {
  int n, m, l, r, w;
  scanf("%d", &n);
  scanf("%d", &m);
  for (int i = (0); i < (m); i++) {
    scanf("%d", &l);
    scanf("%d", &r);
    scanf("%d", &w);
    adj[l].push_back(make_pair(r, w));
    adj[r].push_back(make_pair(l, -w));
  }
  memset(vis, -1, sizeof vis);
  int flag = 1;
  for (int i = 1; i <= n; i++) {
    if (vis[i] != -1) continue;
    vis[i] = 0;
    queue<int> temp;
    temp.push(i);
    while (!temp.empty()) {
      int kp = temp.front();
      temp.pop();
      for (pair<int, int> p : adj[kp]) {
        if (vis[p.first] != -1) {
          if (vis[p.first] - vis[kp] != p.second) {
            flag = 0;
            break;
          }
        } else {
          vis[p.first] = vis[kp] + p.second;
          temp.push(p.first);
        }
      }
      if (!flag) break;
    }
    if (!flag) break;
  }
  if (flag)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}
