#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<pair<int, int>> E[201010];
vector<pair<int, int>> EE[201010];
int vis[201010], col[201010];
string solve() {
  for (int i = 0; i < N; i++)
    if (!vis[i]) {
      col[i] = 0;
      vis[i] = 1;
      queue<int> que;
      que.push(i);
      while (!que.empty()) {
        int q = que.front();
        que.pop();
        for (auto &p : E[q]) {
          if (vis[p.first]) {
            if (col[q] + p.second != col[p.first]) return "No";
          } else {
            col[p.first] = col[q] + p.second;
            vis[p.first] = 1;
            que.push(p.first);
          }
        }
      }
    }
  return "Yes";
}
int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    E[a].push_back({b, c});
  }
  cout << solve() << endl;
  return 0;
}
