#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000;
const int maxlen = 1e9;
int n, m, top = 0;
int vist[maxn + 5];
long long mx[maxn + 5], mi[maxn + 5], dist[maxn + 5];
vector<pair<int, int> > G[maxn + 5];
bool dfs(int x) {
  for (auto it : G[x]) {
    if (!vist[it.first]) {
      vist[it.first] = top;
      dist[it.first] = dist[x] + it.second;
      dfs(it.first);
    } else {
      if (dist[it.first] != dist[x] + it.second) return false;
    }
  }
  return true;
}
int main() {
  int u, v, dd;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d%d", &u, &v, &dd);
    G[u].push_back(make_pair(v, dd));
    G[v].push_back(make_pair(u, -dd));
  }
  for (int i = 1; i <= n; ++i) {
    if (vist[i]) continue;
    ++top;
    vist[i] = top, dist[i] = 0;
    if (!dfs(i)) {
      puts("No");
      exit(0);
    }
  }
  memset(mx, 0x80, sizeof(mx));
  memset(mi, 0x7f, sizeof(mi));
  for (int i = 1; i <= n; ++i) {
    mx[i] = max(mx[i], dist[i]);
    mi[i] = max(mi[i], dist[i]);
  }
  for (int i = 1; i <= top; ++i) {
    if (mx[i] - mi[i] > maxlen) {
      puts("No");
      exit(0);
    }
  }
  puts("Yes");
  return 0;
}
