#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3FFFFFFF;
const long long INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const string INFSTR = "\x7f";
const double EPS = 1.0e-9;
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) {
  return ist >> right.first >> right.second;
}
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) {
  return ost << right.first << ' ' << right.second;
}
template <class T, class TCompatible, size_t N>
void Fill(T (&dest)[N], const TCompatible& val) {
  fill(dest, dest + N, val);
}
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T (&dest)[M][N], const TCompatible& val) {
  for (int i = 0; i < M; ++i) Fill(dest[i], val);
}
template <class T>
T Compare(T left, T right) {
  return left > right ? 1 : (left < right ? -1 : 0);
}
istream& Ignore(istream& ist) {
  string s;
  ist >> s;
  return ist;
}
bool Inside(int i, int j, int h, int w) {
  return i >= 0 && i < h && j >= 0 && j < w;
}
istream& operator>>(istream& ist, __int128& val) {
  long long tmp;
  ist >> tmp;
  val = tmp;
  return ist;
}
ostream& operator<<(ostream& ost, __int128 val) {
  long long tmp = val;
  ost << tmp;
  return ost;
}
template <typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;
int N, K;
vector<pair<long long, long long> > G[100000];
bool used[100000];
long long dist[100000];
bool DFS(int i, int prev) {
  used[i] = true;
  for (pair<long long, long long> e : G[i]) {
    int to = e.first;
    long long cost = e.second;
    if (to == prev) continue;
    if (used[to]) {
      if (dist[to] != dist[i] + cost) return false;
      return true;
    }
    dist[to] = dist[i] + cost;
    if (!DFS(to, i)) return false;
  }
  return true;
}
int main() {
  cin >> N >> K;
  for (long long i = (0); i < (long long)(K); ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    G[a].push_back(pair<long long, long long>(b, c));
    G[b].push_back(pair<long long, long long>(a, -c));
  }
  bool ok = true;
  for (long long i = (0); i < (long long)(N); ++i) {
    if (used[i]) continue;
    dist[i] = 0;
    ok &= DFS(i, -1);
  }
  YesNo(ok);
  return 0;
}
