#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 17;
vector<pair<int, int> > G[MAXN];
int in[MAXN], out[MAXN], plc[MAXN], vis[MAXN];
int main(int argc, char const *argv[]) {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int u, v, d;
    scanf("%d%d%d", &u, &v, &d);
    G[u].push_back({v, d});
    G[v].push_back({u, -d});
    in[v]++;
    out[u]++;
  }
  for (int i = 1; i <= n; ++i) {
    plc[i] = -1;
    vis[i] = 0;
  }
  queue<int> q;
  bool can = true;
  for (int i = 1; i <= n; ++i) {
    if (out[i] || in[i] && !vis[i]) {
      q.push(i);
      while (q.size() && can) {
        int u = q.front();
        q.pop();
        vis[u] = 1;
        if (plc[u] == -1) plc[u] = 317;
        std::cerr << "u"
                  << " = " << (u) << std::endl;
        std::cerr << "plc[u]"
                  << " = " << (plc[u]) << std::endl;
        for (int i = 0; i < G[u].size(); ++i) {
          int v = G[u][i].first, c = G[u][i].second;
          if (plc[v] == -1) {
            plc[v] = plc[u] + c;
            if (!vis[v]) q.push(v);
          } else if (plc[v] != plc[u] + c)
            can = false;
        }
      }
    }
  }
  if (can)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
