#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long INF = 1e+14;
const long double eps = 1e-8;
const long double pi = acos(-1.0);
struct edge {
  int to, distance;
};
vector<edge> G[100100];
int N, M;
bool used[100100];
int x[100100];
void Yes() {
  cout << "Yes" << endl;
  exit(0);
}
void No() {
  cout << "No" << endl;
  exit(0);
}
void dfs(int i) {
  used[i] = true;
  for (int j = 0; j < G[i].size(); j++) {
    int g = G[i][j].to;
    bool flag = used[g];
    int distance = G[i][j].distance;
    if (!flag) {
      x[g] = x[i] + distance;
      flag = true;
    } else {
      if (x[g] != x[i] + distance) No();
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int L, R, D;
    cin >> L >> R >> D;
    L--;
    R--;
    edge es;
    es.to = R;
    es.distance = D;
    G[L].push_back(es);
    es.to = L;
    es.distance = -D;
    G[R].push_back(es);
  }
  for (int i = 0; i < N; i++) used[i] = false;
  for (int i = 0; i < N; i++) {
    if (!(used[i])) {
      x[i] = 0;
      dfs(i);
    }
  }
  Yes();
  return 0;
}
