#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const double EPS = 1e-9;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1},
          dy[] = {0, -1, 0, 1, 1, -1, -1, 1};
struct Query {
  int l, r;
  long long int d;
};
int main() {
  int N, M;
  cin >> N >> M;
  vector<Query> Q;
  for (int i = 0; i < M; i++) {
    int l, r;
    long long int d;
    cin >> l >> r >> d;
    l--, r--;
    if (l > r) {
      d = -d;
      swap(l, r);
    }
    Q.push_back((Query){l, r, d});
  }
  sort(Q.begin(), Q.end(), [](Query l, Query r) { return l.r < r.r; });
  vector<long long int> pos(N, -1);
  bool flag = true;
  for (int i = 0; i < M; i++) {
    if (pos[Q[i].l] == -1 && pos[Q[i].r] == -1) {
      pos[Q[i].l] = 0LL;
      pos[Q[i].r] = Q[i].d;
    } else if (pos[Q[i].l] != -1 && pos[Q[i].r] == -1) {
      pos[Q[i].r] = pos[Q[i].l] + Q[i].d;
    } else if (pos[Q[i].l] == -1 && pos[Q[i].r] != -1) {
      pos[Q[i].l] = pos[Q[i].r] - Q[i].d;
    } else if (pos[Q[i].l] != -1 && pos[Q[i].r] != -1) {
      if (pos[Q[i].r] - pos[Q[i].l] != Q[i].d) {
        flag = false;
        break;
      }
    }
  }
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
