#include <bits/stdc++.h>
using namespace std;
int vx[] = {0, 0, -1, 1};
int vy[] = {1, -1, 0, 0};
int dx[] = {1, 0, -1, 1, -1, 1, 0, -1};
int dy[] = {1, 1, 1, 0, 0, -1, -1, -1};
const long long mod = 1e9 + 7;
const int INF = INT_MAX / 2;
const int MAX = 1e9;
const int MAX_N = 100010;
const int MAX_M = 200020;
int n, m;
int L[MAX_M], R[MAX_M], D[MAX_M];
vector<pair<int, int> > graph[MAX_N];
bool used[MAX_N];
int x[MAX_N];
void dfs(int s) {
  used[s] = true;
  for (int i = 0; i < graph[s].size(); i++) {
    int to = graph[s][i].first;
    if (!used[to]) {
      x[to] = x[s] + graph[s][i].second;
      dfs(to);
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> L[i] >> R[i] >> D[i];
    L[i]--;
    R[i]--;
    graph[L[i]].push_back(pair<int, int>(R[i], D[i]));
  }
  fill(used, used + n, false);
  for (int i = 0; i < n; i++) {
    if (!used[i]) {
      x[i] = 0;
      dfs(i);
    }
  }
  for (int i = 0; i < m; i++) {
    if (x[R[i]] - x[L[i]] != D[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
