#include <bits/stdc++.h>
using namespace std;
bool vis[100001], tepan;
map<int, int> mp;
int n, m;
vector<pair<int, int> > v[100001], z[100001];
struct ac {
  int l, r, d;
} a[200001];
void dfs(int now, int shen) {
  for (int i = 0; i < v[now].size(); i++) {
    int c = v[now][i].first;
    if (!vis[c]) {
      vis[c] = true;
      shen += v[now][i].second;
      if (mp[c] != shen && mp[c] != 0) {
        tepan = true;
        return;
      }
      mp[c] = shen;
      dfs(c, shen);
      if (tepan) return;
      shen -= v[now][i].second;
      vis[c] = false;
    }
  }
}
void dfs2(int now, int shen) {
  for (int i = 0; i < z[now].size(); i++) {
    int c = z[now][i].first;
    if (!vis[c]) {
      vis[c] = true;
      shen -= z[now][i].second;
      if (mp[c] > 0) mp[c] = mp[c] - mp[c] - mp[c];
      if (mp[c] != shen && mp[c] != 0) {
        tepan = true;
        return;
      }
      mp[c] = shen;
      dfs(c, shen);
      if (tepan) return;
      shen += z[now][i].second;
      vis[c] = false;
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> a[i].l >> a[i].r >> a[i].d;
    v[a[i].l].push_back(make_pair(a[i].r, a[i].d));
    z[a[i].r].push_back(make_pair(a[i].l, a[i].d));
  }
  vis[a[1].l] = true;
  dfs(a[1].l, 0);
  dfs2(a[1].l, 0);
  if (tepan)
    cout << "No";
  else
    cout << "Yes";
  return 0;
}
