#include <bits/stdc++.h>
using namespace std;
const int oo = 0x3f3f3f3f;
const int N = 100005;
const int M = 200005;
bool vis[N];
bool ok = 1;
long long dis[N];
vector<pair<int, int> > adj[N];
void dfs(int v, long long d) {
  if (!vis[v] && d != dis[v]) {
    ok = 0;
    return;
  }
  if (vis[v]) return;
  vis[v] = 1;
  dis[v] = d;
  for (auto it : adj[v]) {
    int c_v = it.first;
    long long D = d + it.second;
    dfs(c_v, D);
  }
}
int main() {
  int n, m;
  scanf("%d", &(n));
  scanf("%d", &(m));
  for (int i = 0; i < m; i++) {
    int l, r, d;
    scanf("%d", &(l));
    scanf("%d", &(r));
    scanf("%d", &(d));
    adj[l].push_back(make_pair(r, d));
    adj[r].push_back(make_pair(l, -d));
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i, 0);
  if (!ok)
    cout << "No\n";
  else
    cout << "Yes\n";
}
