#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int l;
  int r;
  int d;
};
static const int N_MAX = 100000;
int n;
int m;
typedef vector<Edge*> VE;
VE l_map[N_MAX];
VE r_map[N_MAX];
int x[N_MAX];
int visited[N_MAX];
bool traverse(int i) {
  if (visited[i]) return true;
  queue<int> q;
  visited[i] = 1;
  x[i] = 0;
  q.push(i);
  while (!q.empty()) {
    int v = q.back();
    q.pop();
    for (auto le : l_map[v]) {
      if (!visited[le->r]) {
        x[le->r] = x[v] + le->d;
        visited[le->r] = 1;
        q.push(le->r);
      } else if (x[le->r] != x[v] + le->d) {
        puts("No");
        return false;
      }
    }
    for (auto re : r_map[v]) {
      if (!visited[re->l]) {
        x[re->l] = x[v] - re->d;
        visited[re->l] = 1;
        q.push(re->l);
      } else if (x[re->l] != x[v] - re->d) {
        puts("No");
        return false;
      }
    }
  }
  return true;
}
int main(int argc, char* argv[]) {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; ++i) {
    Edge* e = new Edge;
    scanf("%d %d %d", &e->l, &e->r, &e->d);
    e->l--;
    e->r--;
    l_map[e->l].push_back(e);
    r_map[e->r].push_back(e);
  }
  for (int i = 0; i < n; i++) {
    x[i] = 0;
    visited[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    if (!traverse(i)) {
      return 0;
    }
  }
  puts("Yes");
}
