#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const long long int INF = 50000000000000;
struct edge {
  long long int to, cost;
  bool operator>(const edge &s) const { return cost > s.cost; }
};
long long int N, M, L[200000 + 10], R[200000 + 10], D[200000 + 10];
vector<edge> G[200000 + 10];
long long int d[200000 + 10];
bool F = true;
long long int ans = 0;
void dijkstra(int s) {
  std::priority_queue<std::pair<int, int>, vector<std::pair<int, int>>,
                      std::greater<std::pair<int, int>>>
      que;
  std::fill(d, d + N, INF);
  d[s] = 0;
  que.push(std::pair<int, int>(0, s));
  while (!que.empty()) {
    std::pair<int, int> p = que.top();
    que.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (int i = 0; i < (signed)G[v].size(); i++) {
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        que.push(std::pair<int, int>(d[e.to], e.to));
      }
    }
  }
}
int main() {
  cin >> N >> M;
  long long int fir = INF;
  long long int S[200000 + 10];
  if (M == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  for (int i = 0; i < signed(M); i++) {
    cin >> L[i] >> R[i] >> D[i];
    L[i]--;
    R[i]--;
    if (abs(R[i] - L[i]) == 1) {
      G[L[i]].push_back({R[i], D[i]});
      G[R[i]].push_back({L[i], D[i]});
    }
  }
  for (int i = 0; i < signed(N - 1); i++) {
    if (G[i].size() == 2) continue;
    if (i == 0 && G[i].size() == 1) continue;
    G[i].push_back({i + 1, 0});
    G[i + 1].push_back({i, 0});
    if (fir == INF) fir = i;
    S[i]++;
  }
  for (int i = 0; i < signed(N - 1); i++) {
    S[i + 1] += S[i];
    {} {}
  }
  dijkstra(0);
  for (int i = 0; i < signed(M); i++) {
    if (abs(R[i] - L[i]) == 1) continue;
    {} {} {} {}
    if (d[max(R[i], L[i])] - d[min(R[i], L[i])] != D[i] &&
        S[max(R[i], L[i]) - 1] - S[min(R[i], L[i])] == 0) {
      F = false;
      break;
    }
  }
  ans = INF + 10;
  cout << (F ? "Yes" : "No") << endl;
}
