#include <bits/stdc++.h>

using namespace std;

const int N = 100010;

vector < pair <int, long long> > g[N];
bool used[N];
long long d[N];

long long mx;

void dfs(int x) {
  used[x] = 1;
  for (auto &e : g[x]) {
    int to = e.first;
    int dist = e.second;
    if (used[to] && d[to] != d[x] + dist) {
      puts("No");
      exit(0);
    } else if (!used[to]) {
      d[to] = d[x] + dist;
      mx = max(mx, d[to]);
      dfs(to);
    }
  }
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int st = 0;
  for (int i = 0; i < m; ++i) {
    int x, y, z;
    scanf("%d %d %d", &x, &y, &z);
    g[x].push_back({y, z});
    g[y].push_back({x, -z});
    st = x;
  }
  mx = -1;
  for (int i = 1; i <= n; ++i) {
    if (!used[i]) {
      ++mx;
      dfs(i);
    }
  }
  puts("Yes");
	return 0;
}