#include <bits/stdc++.h>
using namespace std;
int L[100010], R[100010], D[100010], bcj[100010];
vector<pair<int, int> > v[100010];
int d[100010];
vector<int> vv[100010];
bool vis[100010];
int father(int x) { return bcj[x] == x ? x : bcj[x] = father(bcj[x]); }
void join(int x, int y) {
  int fx = father(x);
  int fy = father(y);
  if (fx != fy) bcj[fx] = fy;
}
bool dfs(int x) {
  bool flag = true;
  vis[x] = true;
  for (int i = 0; i < v[x].size(); i++) {
    int f = v[x][i].first;
    int s = v[x][i].second;
    if (vis[f]) {
      if (d[f] == d[x] + s)
        continue;
      else
        return false;
    } else {
      d[f] = d[x] + s;
      flag &= dfs(f);
    }
  }
  return flag;
}
int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 1; i <= N; i++) bcj[i] = i;
  for (int i = 1; i <= M; i++) {
    scanf("%d%d%d", &L[i], &R[i], &D[i]);
    v[L[i]].push_back(make_pair(R[i], D[i]));
    v[R[i]].push_back(make_pair(L[i], -D[i]));
    join(L[i], R[i]);
  }
  for (int i = 1; i <= N; i++) bcj[i] = father(bcj[i]);
  for (int i = 1; i <= N; i++) vv[bcj[i]].push_back(i);
  bool flag = true;
  for (int i = 1; i <= N; i++) {
    if (vv[i].size()) {
      d[i] = true;
      flag &= dfs(i);
    }
  }
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
