#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, -1, 1};
int dy[] = {-1, 1, 0, 0};
int toInt(string s) {
  int r = 0;
  istringstream sin(s);
  sin >> r;
  return r;
}
const int N = 1e5 + 3;
int n, start, m, l, r, d;
vector<pair<int, int> > adj[N];
bool done[N], calc[N];
map<int, int> dist;
int main() {
  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  cout << fixed;
  cin >> n >> m;
  for (long long int i = (1); i <= (n); i++) done[i] = calc[i] = false;
  for (long long int i = (1); i <= (m); i++) {
    cin >> l >> r >> d;
    adj[l].push_back(make_pair(r, d));
    adj[r].push_back(make_pair(l, -d));
    done[l] = done[r] = true;
  }
  start = n + 1;
  for (long long int i = (1); i <= (n); i++) {
    if (done[i]) {
      dist[i] = 0;
      start = i;
      break;
    }
  }
  for (long long int i = (start); i <= (n); i++) {
    if (done[i] and !calc[i]) {
      queue<int> Q;
      Q.push(i);
      calc[i] = true;
      while (!Q.empty()) {
        int x = Q.front();
        int dx = dist[x];
        Q.pop();
        for (auto u : adj[x]) {
          r = u.first;
          d = u.second;
          if (!dist[r]) {
            dist[r] = dx + d;
            if (!calc[r]) {
              calc[r] = false;
              Q.push(r);
            }
          } else {
            if (dist[r] - dx != d) {
              cout << "No" << endl;
              return 0;
            }
          }
        }
      }
    }
  }
  cout << "Yes" << endl;
}
