#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
vector<pair<int, int> > g[111111];
long long dist[111111];
bool ok = true;
void dfs(int u) {
  for (int i = 0; i < g[u].size() && ok; i++) {
    int v = g[u][i].first;
    if (dist[v] == -1) {
      dist[v] = dist[u] + (long long)g[u][i].second;
      dfs(v);
    } else if (abs(dist[u] - g[u][i].second) != dist[v]) {
      ok = false;
      return;
    }
  }
}
int main() {
  int n, m, u, v, w;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d %d", &u, &v, &w);
    g[u].push_back(make_pair(v, w));
    g[v].push_back(make_pair(u, w));
  }
  memset((dist), (-1), sizeof(dist));
  for (int i = 1; i <= n && ok; i++) {
    if (dist[i] == -1) {
      dist[i] = 0;
      dfs(i);
    }
  }
  if (ok)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}
