#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int from, to;
  long long dist;
  Edge(int u, int v, long long d) : from(u), to(v), dist(d) {}
};
vector<int> G[100005];
vector<Edge> edges;
int flag = 1, s;
long long d[100005];
int done[100005];
void dfs(int u) {
  if (flag == 0) return;
  done[u] = 1;
  for (int i = 0; i < G[u].size(); i++) {
    if (flag == 0) return;
    Edge& e = edges[G[u][i]];
    if (!done[e.to]) {
      d[e.to] = d[e.from] + e.dist;
      dfs(e.to);
    } else {
      if (d[e.to] != d[u] + e.dist) {
        flag = 0;
        return;
      }
    }
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int l, r, d;
    scanf("%d%d%d", &l, &r, &d);
    edges.push_back(Edge(l, r, d));
    G[l].push_back(i);
  }
  for (int i = 1; i <= n; i++) {
    if (flag == 0) break;
    if (!G[i].empty()) {
      s = i;
      memset(d, 0, sizeof(d));
      memset(done, 0, sizeof(done));
      dfs(s);
    }
  }
  if (flag)
    cout << "Yes";
  else
    cout << "No";
}
