#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int maxn = 100000 + 5;
const long long INF = 1000000000000000LL;
const int P = 1000000007;
const double PI = acos(-1.0);
template <typename T>
inline T read(T &x) {
  x = 0;
  int _f = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') _f |= (ch == '-'), ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x = _f ? -x : x;
}
template <class T1, class T2>
inline void gmax(T1 &a, T2 b) {
  if (b > a) a = b;
}
template <class T1, class T2>
inline void gmin(T1 &a, T2 b) {
  if (b < a) a = b;
}
int n, m, L, R, D, in[maxn];
map<int, int> mp;
set<int> second;
vector<pair<int, int> > G[maxn];
int main() {
  read(n), read(m);
  for (int i = 1; i <= m; i++) {
    read(L), read(R), read(D);
    if (D) {
      G[R].push_back(make_pair(L, D));
      in[L]++;
    }
    second.insert(L), second.insert(R);
  }
  queue<int> Q;
  for (set<int>::iterator it = second.begin(); it != second.end(); ++it) {
    if (in[(*it)] == 0) Q.push(*it), mp[*it] = 0;
  }
  int sum = 0;
  while (!Q.empty()) {
    int x = Q.front();
    Q.pop();
    sum++;
    for (int i = 0; i < (int)G[x].size(); i++) {
      pair<int, int> _ = G[x][i];
      if (--in[G[x][i].first] == 0) Q.push(G[x][i].first);
      if (mp[x] + G[x][i].second < mp[G[x][i].first]) return puts("No"), 0;
      mp[G[x][i].first] = max(mp[x] + G[x][i].second, mp[G[x][i].first]);
      if (mp[G[x][i].first] > 1e9) return puts("No"), 0;
    }
  }
  if (sum != second.size())
    puts("No");
  else
    puts("Yes");
  return 0;
}
