#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
struct edge {
  int to;
  int cost;
};
int d[10000];
bool f;
int V;
vector<edge> G[10000];
bool mem[10000];
void DFS(int u) {
  mem[u] = true;
  for (int i = 0; i < (G[u].size()); i++) {
    if (!mem[G[u][i].to]) {
      d[G[u][i].to] = d[u] + G[u][i].cost;
      DFS(G[u][i].to);
    } else {
      if (d[G[u][i].to] != d[u] + G[u][i].cost) {
        f = false;
      }
    }
  }
}
int main() {
  int E, r;
  f = true;
  cin >> V >> E;
  for (int i = 0; i < (E); i++) {
    int f, t, c;
    cin >> f >> t >> c;
    f--;
    t--;
    edge e = {t, c};
    G[f].push_back(e);
    e.cost = -1 * c;
    e.to = f;
    G[t].push_back(e);
  }
  for (int i = 0; i < (10000); i++) {
    mem[i] = false;
  }
  for (int i = 1; i <= V; i++) {
    if (!mem[i]) {
      d[i] = 0;
      DFS(i);
    }
  }
  if (f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
