#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;
vector<Edge> l_map[N_MAX];
vector<Edge> 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 (const auto& le : l_map[v]) {
      if (!visited[le.r]) {
        x[le.r] = x[v] + le.d;
        visited[le.r] = 1;
        q.push(le.r);
      }
    }
    for (const auto& re : r_map[v]) {
      if (!visited[re.l]) {
        x[re.l] = x[v] - re.d;
        visited[re.l] = 1;
        q.push(re.l);
      }
    }
  }
  return true;
}
int main(int argc, char* argv[]) {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; ++i) {
    Edge e;
    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++) {
    traverse(i);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < l_map[i].size(); ++j) {
      if (x[l_map[i][j].r] - x[l_map[i][j].l] != l_map[i][j].d) {
        puts("No");
        return 0;
      }
    }
  }
  puts("Yes");
}
