#include <bits/stdc++.h>
using namespace std;
using LD = long double;
using VB = vector<bool>;
using WB = vector<VB>;
using VC = vector<char>;
using WC = vector<VC>;
using VI = vector<long long>;
using WI = vector<VI>;
using VD = vector<LD>;
using WD = vector<VD>;
using VS = vector<string>;
using WS = vector<VS>;
using PI = pair<long long, long long>;
using TI = tuple<long long, long long, long long>;
using VPI = vector<PI>;
using WPI = vector<VPI>;
bool debug;
void solve();
signed main(signed argc, char* argv[]) {
  debug = false;
  if (!debug) {
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
  cout << fixed << setprecision(20);
  cerr << fixed << setprecision(20);
  solve();
  return 0;
}
template <class T>
istream& operator>>(istream& s, vector<T>& v) {
  for (auto&& p : v) s >> p;
  return s;
}
template <class T>
ostream& operator<<(ostream& s, vector<T> v) {
  long long i = 0;
  for (const auto& p : v) s << (i++ ? " " : "") << p;
  return s;
}
template <class T>
ostream& operator<<(ostream& s, vector<vector<T>> w) {
  for (const auto& v : w) {
    long long i = 0;
    for (const auto& p : v) s << (i++ ? " " : "") << p;
    s << '\n';
  }
  return s;
}
template <class T>
T& RD(T& t) {
  cin >> t;
  return t;
}
template <class T, class... A>
T RD(A... a) {
  T t(a...);
  cin >> t;
  return t;
}
template <class T>
T max(const pair<T, T>& p) {
  return max(p.first, p.second);
}
template <class T>
T min(const pair<T, T>& p) {
  return min(p.first, p.second);
}
inline LD AC(LD d) { return d ? d : 0; }
constexpr long long INF = 1LL << 60;
constexpr long long MOD = 1000000009;
long long N, M;
vector<map<long long, long long>> path;
VI x;
void dfs(long long i, long long y) {
  if (debug)
    cerr << "i"
         << " = " << (i) << ", ";
  if (debug)
    cerr << "y"
         << " = " << (y) << '\n';
  if (x[i] == INF) x[i] = y;
  if (x[i] != y) {
    cout << "No" << '\n';
    if (debug)
      cerr << "i"
           << " = " << (i) << ", ";
    if (debug)
      cerr << "y"
           << " = " << (y) << ", ";
    if (debug)
      cerr << "x"
           << " = " << (x) << '\n';
    exit(0);
  }
  for (auto& p : path[i]) {
    long long j, t;
    tie(j, t) = p;
    if (t != INF) {
      path[i][j] = INF;
      dfs(j, y + t);
    }
  }
}
void solve() {
  long long N, M;
  cin >> N >> M;
  path = vector<map<long long, long long>>(N);
  x = VI(N, INF);
  for (auto i0_to = (M), i = decltype(M)(0); i < i0_to; i++) {
    long long U, V, D;
    cin >> U >> V >> D;
    path[U - 1][V - 1] = D;
    path[V - 1][U - 1] = -D;
  }
  for (auto i0_to = (N), i = decltype(N)(0); i < i0_to; i++)
    if (x[i] == INF) dfs(i, 0);
  cout << "Yes" << '\n';
}
