#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, M;
  cin >> N >> M;
  vector<vector<pair<long long, long long> > > v(N + 3);
  long long l, r, d;
  while (M--) {
    cin >> l >> r >> d;
    v[l].push_back(pair<long long, long long>(r, d));
    v[r].push_back(pair<long long, long long>(l, -d));
  }
  bool visited[100010];
  long long position[100010];
  memset(visited, 0, sizeof visited);
  bool can = true;
  for (int i = 1; i <= N; ++i) {
    if (!visited[i]) {
      queue<long long> q;
      q.push(i);
      position[i] = 0;
      while (!q.empty()) {
        auto idx = q.front();
        q.pop();
        visited[idx] = true;
        for (auto node : v[idx]) {
          if (!visited[node.first]) {
            position[node.first] = position[idx] + node.second;
            q.push(node.first);
          } else if (position[idx] + node.second != position[node.first]) {
            can = false;
            goto xgh;
          }
        }
      }
    }
  }
xgh:
  if (can)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}
