#include <bits/stdc++.h>
using namespace std;
int lev[1000010], dis[1000010], st[1000010], col, en[1000010], vis[1000010],
    in[1000010];
vector<int> mat[1000010], cost[1000010], ty[1000010];
stack<int> stk;
int top_sort(int p) {
  st[p] = col;
  int temp = 0;
  for (int i = 0; i <= (int)mat[p].size() - 1; i++) {
    int x = mat[p][i];
    if (st[x] != col && ty[p][i]) temp = max(temp, top_sort(x));
  }
  if (!in[p]) stk.push(p), in[p] = 1;
  en[p] = col;
  return temp;
}
int dfs(int p) {
  st[p] = col;
  int temp = 0;
  for (int i = 0; i <= (int)mat[p].size() - 1; i++) {
    int x = mat[p][i];
    if (st[x] != col) {
      if (ty[p][i]) {
        dis[x] = dis[p] + cost[p][i];
        temp = max(temp, dfs(x));
      } else {
        dis[x] = dis[p] - cost[p][i];
        temp = max(temp, dfs(x));
      }
    } else {
      int v = dis[x] - dis[p];
      if (v != cost[p][i]) return 1;
    }
  }
  en[p] = col;
  return temp;
}
int main() {
  ios::sync_with_stdio(false);
  int n, m, a, b, c, x, y, z;
  cin >> n >> m;
  for (int i = 0; i <= m - 1; i++) {
    cin >> a >> b >> c;
    mat[a].push_back(b);
    cost[a].push_back(c);
    ty[a].push_back(1);
    mat[b].push_back(a);
    cost[b].push_back(c);
    ty[b].push_back(0);
  }
  col = 1;
  for (int i = 1; i <= n; i++)
    if (st[i] != col) top_sort(i), col++;
  while (!stk.empty()) {
    int x = stk.top();
    if (st[x] != col) {
      col++;
      if (dfs(x)) {
        cout << "No" << endl;
        return 0;
      }
    }
    stk.pop();
  }
  cout << "Yes";
  return 0;
}
