#include <bits/stdc++.h>
using namespace std;
void solve();
void read_input() {}
void solve() {}
vector<pair<int, int> > edges[100005];
vector<int> order;
bool visited[100005];
long long pos[100005];
void dfs(int i) {
  if (visited[i]) return;
  visited[i] = true;
  for (pair<int, int> p : edges[i]) {
    if (!visited[p.first]) dfs(p.first);
    order.push_back(i);
  }
}
int main() {
  memset(pos, -1, sizeof(pos));
  for (int i = 0; i < 100005; i++) {
    edges[i] = vector<pair<int, int> >();
  }
  int N, M;
  scanf("%d %d", &N, &M);
  for (int i = 0; i < M; i++) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    edges[a].push_back({b, c});
  }
  for (int i = 1; i <= N; i++) {
    if (!visited[i]) {
      dfs(i);
    }
  }
  reverse(order.begin(), order.end());
  for (int i : order) {
    if (pos[i] == -1) {
      pos[i] = 0;
    }
    for (pair<int, int> p : edges[i]) {
      if (pos[p.first] == -1) {
        pos[p.first] = pos[i] + p.second;
      } else {
        if (pos[p.first] != pos[i] + p.second) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  for (int i = 0; i < N; i++) {
    if (pos[i] > 1000000000) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
