#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T1, class T2>
ostream& operator<<(ostream& s, pair<T1, T2> P) {
  return s << '<' << P.first << ", " << P.second << '>';
}
template <class T>
ostream& operator<<(ostream& s, vector<T> P) {
  for (int i = 0; i < P.size(); ++i) {
    if (i > 0) {
      s << " ";
    }
    s << P[i];
  }
  return s;
}
template <class T>
ostream& operator<<(ostream& s, vector<vector<T> > P) {
  for (int i = 0; i < P.size(); ++i) {
    s << endl << P[i];
  }
  return s << endl;
}
template <class T>
ostream& operator<<(ostream& s, set<T> P) {
  for (__typeof__((P).begin()) it = (P).begin(); it != (P).end(); ++it) {
    s << "<" << *it << "> ";
  }
  return s << endl;
}
template <class T1, class T2>
ostream& operator<<(ostream& s, map<T1, T2> P) {
  for (__typeof__((P).begin()) it = (P).begin(); it != (P).end(); ++it) {
    s << "<" << it->first << "->" << it->second << "> ";
  }
  return s << endl;
}
const int MAX = 410000;
vector<pair<int, int> > G[MAX];
const int INF = 1 << 29;
int N, M;
int L[MAX], R[MAX], D[MAX];
int dp[MAX];
bool seen[MAX];
string solve() {
  memset(seen, 0, sizeof(seen));
  for (int i = 0; i < N; ++i) {
    if (seen[i]) continue;
    dp[i] = 0;
    for (int iter = 0; iter < N; ++iter) {
      bool update = false;
      for (int j = 0; j < N; ++j) {
        for (auto e : G[j]) {
          if (!seen[e.first])
            dp[e.first] = dp[j] + e.second, update = true;
          else
            chmin(dp[e.first], dp[j] + e.second), update = true;
        }
      }
      if (!update) break;
    }
  }
  for (int i = 0; i < M; ++i) {
    if (dp[R[i]] - dp[L[i]] != D[i]) return "No";
  }
  return "Yes";
}
int main() {
  while (cin >> N >> M) {
    for (int i = 0; i < MAX; ++i) G[i].clear();
    for (int i = 0; i < M; ++i) {
      int a, b, c;
      cin >> a >> b >> c;
      --a, --b;
      L[i] = a, R[i] = b, D[i] = c;
      G[a].push_back(pair<int, int>(b, c));
      G[b].push_back(pair<int, int>(a, -c));
    }
    cout << solve() << endl;
  }
}
