#include <bits/stdc++.h>
using namespace std;
template <class T>
T smin(T &a, T b) {
  if (a > b) a = b;
  return a;
}
template <class T>
T smax(T &a, T b) {
  if (a < b) a = b;
  return a;
}
const int N = (int)(1e6) + 5;
vector<pair<int, int> > g[N];
const int oo = 1e9 + 69;
int D[N];
int main(void) {
  int n, m;
  ios_base ::sync_with_stdio(0);
  cin >> n >> m;
  vector<vector<int> > v(m, vector<int>(3, 0));
  for (auto &it : v)
    for (int i = 0; i < 3; ++i) cin >> it[i];
  for (auto it : v)
    g[it[0]].push_back(make_pair(it[1], it[2])),
        g[it[1]].push_back(make_pair(it[0], -it[2]));
  for (int i = 1; i <= n; ++i) D[i] = -oo;
  for (int i = 1; i <= n; ++i)
    if (D[i] == -oo) {
      D[i] = 0;
      queue<int> Q;
      Q.push(i);
      while (!Q.empty()) {
        int node = Q.front();
        Q.pop();
        for (auto it : g[node])
          if (D[it.first] == -oo)
            D[it.first] = D[node] + it.second, Q.push(it.first);
      }
    }
  for (auto it : v)
    if (D[it[1]] - D[it[0]] != it[2]) return puts("No") * 0;
  return 0;
  puts("Yes");
  return 0;
}
