#include <bits/stdc++.h>
using namespace std;
void Debug() { cout << '\n'; }
template <class FIRST, class... REST>
void Debug(FIRST arg, REST... rest) {
  cout << arg << " ";
  Debug(rest...);
}
template <class T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  if (!v.empty()) {
    for (int i = int(0); i < int((int)(v).size() - 1); i++) out << v[i] << ", ";
    out << v.back();
  }
  out << "]";
  return out;
}
template <class S, class T>
ostream& operator<<(ostream& out, const pair<S, T>& v) {
  out << "(" << v.first << ", " << v.second << ")";
  return out;
}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const long long mod = 1000000007;
const int inf = 1 << 29;
const long long linf = 1LL << 60;
const double PI = 3.14159265358979323846;
int N, M;
long long dist[MAX_N];
bool used[MAX_N];
vector<pair<int, int> > G[MAX_N];
bool loop(int v) {
  used[v] = true;
  for (int i = int(0); i < int((int)(G[v]).size()); i++) {
    int n = G[v][i].first, c = G[v][i].second;
    if (dist[n] == -linf) {
      dist[n] = dist[v] + c;
    } else {
      if (dist[n] != dist[v] + c) {
        return false;
      }
    }
    if (!used[n]) return loop(n);
  }
  return true;
}
void solve() {
  cin >> N >> M;
  for (int i = int(0); i < int(M); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    G[a].push_back(pair<int, int>(b, c));
    G[b].push_back(pair<int, int>(a, -c));
  }
  fill(dist, dist + N, -linf);
  for (int i = int(0); i < int(N); i++) {
    if (used[i]) continue;
    dist[i] = 0;
    if (!loop(i)) {
      cout << "No\n";
      return;
    }
  }
  cout << "Yes\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed;
  cout.precision(20);
  srand((unsigned int)time(NULL));
  solve();
  return 0;
}
