#include <bits/stdc++.h>
using namespace std;
const int N = 300000;
const int LIM = 1e9;
const int INF = 1 << 30;
struct tData {
  int v, dis;
};
vector<tData> p[N];
int n, m, _min, _max, pos[N];
bool visited[N];
inline bool solve(int u) {
  visited[u] = true;
  _min = min(pos[u], _min);
  _max = max(pos[u], _max);
  int lim = p[u].size();
  for (int i = 0; i < lim; i++) {
    int v = p[u][i].v, d = p[u][i].dis;
    if (visited[v]) {
      if (pos[v] - pos[u] != d) return false;
      continue;
    }
    pos[v] = pos[u] + d;
    if (pos[v] > LIM || pos[v] < -LIM) return false;
    solve(v);
  }
  return true;
}
int main() {
  scanf("%d%d", &n, &m);
  int l, r, dis;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &l, &r, &dis);
    p[l].push_back((tData){r, dis});
    p[r].push_back((tData){l, -dis});
  }
  for (int i = 1; i <= n; i++) {
    if (visited[i]) continue;
    _min = INF, _max = -INF;
    pos[i] = 0;
    if (!solve(i)) {
      puts("No");
      return 0;
    }
    if (_max - _min > LIM + 1) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}
