#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll mod = 1e9 + 7;
const ll INF = 10000000000;
const int MAX_N = 100000;
int main() {
  cin.sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  if (M == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  map<int, ll> mp;
  map<pair<int, int>, int> mp2;
  vector<pair<int, int>> P(M);
  vector<ll> R(M), L(M), D(M);
  set<int> st;
  vector<vector<int>> path(N);
  for (int i = 0; i < (int)(M); i++) {
    int d;
    cin >> P[i].first >> P[i].second >> d;
    P[i].first--;
    P[i].second--;
    if (P[i].first > P[i].second) {
      swap(P[i].first, P[i].second);
      d = -d;
    }
    st.insert(P[i].first);
    st.insert(P[i].second);
    mp2[P[i]] = d;
    path[P[i].first].push_back(P[i].second);
    path[P[i].second].push_back(P[i].first);
  }
  int cnt = st.size();
  sort(P.begin(), P.end());
  ll start = 100000000000;
  for (int i = 0; i < (int)(N); i++) {
    if (mp[i] == 0) {
      mp[i] = start;
      queue<pair<int, int>> que;
      for (int j = 0; j < (int)(path[i].size()); j++) {
        if (mp[path[i][j]] == 0) que.push({i, path[i][j]});
      }
      while (que.size()) {
        pair<int, int> K = que.front();
        que.pop();
        int k = K.second;
        for (int l = 0; l < (int)(path[k].size()); l++)
          if (mp[path[k][l]] == 0) que.push({k, path[k][l]});
        if (mp[k] == 0) {
          int d = mp2[{min(k, K.first), max(k, K.first)}];
          mp[k] = (k > K.first ? mp[K.first] + d : mp[K.first] - d);
        }
      }
    }
  }
  for (int i = 0; i < (int)(M); i++) {
    int R = P[i].second, L = P[i].first, D = mp2[P[i]];
    if (mp[R] - mp[L] != D) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
