#include <bits/stdc++.h>
using namespace std;
int INF = (1LL << 30) - 1;
int MOD = 1e9 + 7;
int N, M;
vector<pair<int, int> > graph[200010];
vector<int> dist;
bool dfs(int now, int d) {
  dist[now] = d;
  for (auto p : graph[now]) {
    if (dist[p.first] != INF) {
      if (dist[p.first] != d + p.second)
        return true;
      else
        return false;
    }
    if (dfs(p.first, d + p.second)) return true;
  }
  return false;
}
int main() {
  cin >> N >> M;
  int num = 0;
  for (int i = int(0); i < int(M); ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    graph[a].emplace_back(b, c);
    graph[b].emplace_back(a, -c);
    num = a;
  }
  dist = vector<int>(N, INF);
  for (int i = int(0); i < int(N); ++i) {
    int cost = dist[i];
    if (cost == INF) cost = 0;
    if (dfs(i, cost)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}
