#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 5;
vector<pair<int, int> > adj1[maxn], adj[maxn];
int n, m;
int bel[maxn], scc, pre[maxn], low[maxn], tt;
stack<int> stk;
inline void tarjan(int u) {
  pre[u] = low[u] = ++tt;
  stk.push(u);
  for (int i = 0; i < adj1[u].size(); i++) {
    int v = adj1[u][i].first;
    if (pre[v] == 0) {
      tarjan(v);
      low[u] = min(low[v], low[u]);
    } else if (bel[v] == 0) {
      low[u] = min(low[u], pre[v]);
    }
  }
  if (pre[u] == low[u]) {
    scc++;
    while (1) {
      int v = stk.top();
      stk.pop();
      bel[v] = scc;
      if (v == u) break;
    }
  }
}
int id[maxn], mem[maxn];
map<int, int> mp[maxn];
int d[maxn];
inline void dfs(int u, int curs) {
  if (d[u] != -1) return;
  d[u] = curs;
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i].first;
    int w = adj[u][i].second;
    dfs(v, curs + w);
    break;
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    adj1[u].push_back(make_pair(v, w));
  }
  for (int i = 1; i <= n; i++) {
    if (pre[i] == 0) tarjan(i);
  }
  bool flg = 1;
  for (int i = 1; i <= n; i++) {
    int u = i;
    for (int j = 0; j < adj1[u].size(); j++) {
      int v = adj1[u][j].first;
      int w = adj1[u][j].second;
      if (bel[u] == bel[v]) {
        if (w != 0) {
          flg = 0;
          break;
        }
      } else {
        if (mp[bel[u]].count(bel[v])) {
          if (mp[bel[u]][bel[v]] != w) {
            flg = 0;
            break;
          }
          continue;
        }
        adj[bel[u]].push_back(make_pair(bel[v], w));
        mp[bel[u]][bel[v]] = w;
        id[bel[v]] = 1;
      }
    }
  }
  if (flg == 0) {
    cout << "No" << endl;
    return 0;
  }
  memset(d, -1, sizeof(d));
  for (int i = 1; i <= scc; i++) {
    if (id[i] == 0) {
      for (int j = 0; j < adj[i].size(); j++) {
        int v = adj[i][j].first;
        int w = adj[i][j].second;
        if (d[v] != -1) {
          d[i] = d[v] - w;
          break;
        }
      }
      for (int j = 0; j < adj[i].size(); j++) {
        int v = adj[i][j].first;
        int w = adj[i][j].second;
        dfs(v, d[i] + w);
      }
    }
  }
  for (int u = 1; u <= scc; u++) {
    for (int i = 0; i < adj[u].size(); i++) {
      int v = adj[u][i].first;
      int w = adj[u][i].second;
      if (d[u] + w != d[v]) {
        flg = 0;
        break;
      }
    }
  }
  if (flg)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
