#include <bits/stdc++.h>
using namespace std;
struct e {
  int to, cst;
  e(int x = 0, int y = 0) {
    to = x;
    cst = y;
  }
};
vector<e> adj[100005];
bool vis[100005], b;
int n, m, l, r, d, dis[100005];
bool dfs(int x, int cur_dis) {
  vis[x] = true;
  if (dis[x] != -1 && dis[x] != cur_dis) return false;
  dis[x] = cur_dis;
  bool f = true;
  for (int i = 0; i < adj[x].size(); i++) {
    f = f && dfs(adj[x][i].to, cur_dis + adj[x][i].cst);
  }
  return f;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> l >> r >> d;
    if (l < r)
      adj[l].push_back(e(r, d));
    else
      adj[r].push_back(e(l, -d));
  }
  for (int i = 1; i <= n; i++) {
    b = true;
    if (!vis[i]) {
      memset(dis, -1, sizeof(dis));
      b = dfs(i, 0);
    }
    if (!b) {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}
