#include <bits/stdc++.h>
using namespace std;
const int dirx[] = {-2, -1, 1, 2, 1, -1};
const int diry[] = {0, 1, 1, 0, -1, -1};
inline void debugMode() {}
int n, m, first[100100], second[100100], z[100100], val[100100];
vector<int> V[100100];
bool in[100100], u = 1, done[100100];
map<pair<int, int>, int> M;
void dfs(int first) {
  for (auto it : V[first]) {
    if (val[it] == 2e9) {
      val[it] = val[first] + M[{first, it}];
    } else {
      if (val[first] + M[{first, it}] != val[it]) u = 0;
    }
    dfs(it);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  if (!m) return cout << "Yes", 0;
  for (int i = 1; i <= m; i++) {
    cin >> first[i] >> second[i] >> z[i];
    M[{first[i], second[i]}] = z[i];
    V[first[i]].push_back(second[i]);
    in[second[i]] = 1;
    done[first[i]] = done[second[i]] = 1;
  }
  for (int i = 1; i <= n; i++) {
    if (in[i]) done[i] = 0;
    val[i] = 2e9;
  }
  int nr = 0;
  for (int i = 1; i <= n; i++) {
    nr += done[i] == 1;
  }
  if (nr == 0) return cout << "No", 0;
  int cnt = 0;
  for (int it = 1; it <= n; it++) {
    if (!done[it]) continue;
    u = 1;
    val[it] = cnt++;
    dfs(it);
    if (!u) return cout << "No", 0;
  }
  cout << "Yes";
  return 0;
}
