#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > graph[100005];
vector<pair<int, int> > rgraph[100005];
int deg[100005];
int dis[100005];
bool vis[100005];
int cp;
int comp[100005];
map<int, bool> appeared;
vector<int> order;
void dfs1(int u) {
  vis[u] = true;
  for (int i = 0; i < graph[u].size(); i++) {
    int v = graph[u][i].first;
    if (!vis[v]) dfs1(v);
  }
  order.push_back(u);
}
void dfs2(int u) {
  vis[u] = true;
  comp[u] = cp;
  for (int i = 0; i < rgraph[u].size(); i++) {
    int v = rgraph[u][i].first;
    if (!vis[v]) dfs2(v);
  }
}
int main() {
  ios::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  if (m == 0) {
    cout << "Yes\n";
    return 0;
  }
  for (int i = 0; i < m; i++) {
    int l, r, d;
    scanf("%d %d %d", &l, &r, &d);
    graph[l].push_back({r, d});
    rgraph[r].push_back({l, d});
    deg[r]++;
    appeared[l] = 1;
    appeared[r] = 1;
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) dfs1(i);
  }
  memset(vis, 0, sizeof(vis));
  reverse(order.begin(), order.end());
  for (int i = 0; i < order.size(); i++) {
    int v = order[i];
    if (!vis[v]) {
      dfs2(v);
      cp++;
    }
  }
  if (appeared.size() != cp) {
    cout << "No\n";
    return 0;
  }
  queue<int> q;
  for (int i = 1; i <= n; i++) {
    if (appeared[i] && deg[i] == 0) {
      q.push(i);
      dis[i] = 0;
    }
  }
  while (!q.empty()) {
    int at = q.front();
    q.pop();
    for (int i = 0; i < graph[at].size(); i++) {
      int v = graph[at][i].first;
      int c = graph[at][i].second;
      if (dis[v] != 0) {
        if (dis[at] + c != dis[v]) {
          cout << "No\n";
          return 0;
        } else {
          q.push(v);
        }
      } else {
        dis[v] = dis[at] + c;
        q.push(v);
      }
    }
  }
  cout << "Yes\n";
  return 0;
}
