#include <bits/stdc++.h>
using namespace std;
const int INF = (0x7FFFFFFFL);
const long long INFF = (0x7FFFFFFFFFFFFFFFL);
const string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int MOD = 1e9 + 7;
const int MODD = 998244353;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1.0);
const double EPS = 1e-9;
const string Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int dy[9] = {0, 1, 0, -1, -1, -1, 1, 1, 0};
template <typename T>
void MACRO_VAR_Scan(T &t) {
  cin >> t;
}
template <typename First, typename... Rest>
void MACRO_VAR_Scan(First &first, Rest &...rest) {
  cin >> first;
  MACRO_VAR_Scan(rest...);
}
template <class T>
ostream &operator<<(ostream &o, const vector<T> &j) {
  o << "{";
  for (int i = 0; i < (int)j.size(); ++i) o << (i > 0 ? ", " : "") << j[i];
  o << "}";
  return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U> &j) {
  o << "{" << j.first << ", " << j.second << "}";
  return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U> &j) {
  o << "{";
  for (auto t = j.begin(); t != j.end(); ++t)
    o << (t != j.begin() ? ", " : "") << *t;
  o << "}";
  return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T> &j) {
  o << "{";
  for (auto t = j.begin(); t != j.end(); ++t)
    o << (t != j.begin() ? ", " : "") << *t;
  o << "}";
  return o;
}
inline int print(void) {
  cout << endl;
  return 0;
}
template <class Head>
int print(Head &&head) {
  cout << head;
  print();
  return 0;
}
template <class Head, class... Tail>
int print(Head &&head, Tail &&...tail) {
  cout << head << " ";
  print(forward<Tail>(tail)...);
  return 0;
}
inline int debug(void) {
  cerr << endl;
  return 0;
}
template <class Head>
int debug(Head &&head) {
  cerr << head;
  debug();
  return 0;
}
template <class Head, class... Tail>
int debug(Head &&head, Tail &&...tail) {
  cerr << head << " ";
  debug(forward<Tail>(tail)...);
  return 0;
}
template <typename T>
void PA(T &a) {
  int ASIZE = sizeof(a) / sizeof(a[0]);
  for (int ii = 0; ii < ASIZE; ++ii) {
    cout << a[ii] << " \n"[ii == ASIZE - 1];
  }
}
template <typename T>
void PV(T &v) {
  int VSIZE = v.size();
  for (int ii = 0; ii < VSIZE; ++ii) {
    cout << v[ii] << " \n"[ii == VSIZE - 1];
  }
}
inline int YES(bool x) {
  cout << ((x) ? "YES" : "NO") << endl;
  return 0;
}
inline int Yes(bool x) {
  cout << ((x) ? "Yes" : "No") << endl;
  return 0;
}
inline int yes(bool x) {
  cout << ((x) ? "yes" : "no") << endl;
  return 0;
}
inline int yES(bool x) {
  cout << ((x) ? "yES" : "nO") << endl;
  return 0;
}
inline int Yay(bool x) {
  cout << ((x) ? "Yay!" : ":(") << endl;
  return 0;
}
template <typename A, typename B>
void sankou(bool x, A a, B b) {
  cout << ((x) ? (a) : (b)) << endl;
}
inline long long MOP(long long x, long long n, long long m = MOD) {
  long long r = 1;
  while (n > 0) {
    if (n & 1) (r *= x) %= m;
    (x *= x) %= m;
    n >>= 1;
  }
  return r;
}
inline long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
inline long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
inline long long POW(long long a, long long b) {
  long long c = 1ll;
  do {
    if (b & 1) c *= 1ll * a;
    a *= 1ll * a;
  } while (b >>= 1);
  return c;
}
template <typename T, typename A, typename B>
inline bool between(T x, A a, B b) {
  return ((a <= x) && (x < b));
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
template <typename A, typename B>
inline bool chmax(A &a, const B &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename A, typename B>
inline bool chmin(A &a, const B &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
struct abracadabra {
  abracadabra() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(5);
  };
} ABRACADABRA;
template <typename T>
struct UnionFind_Weight {
  vector<int> parent;
  vector<int> rank;
  vector<T> diff_weight;
  UnionFind_Weight(int n = 1, T SUM_UNITY = 0) { init(n, SUM_UNITY); }
  void init(int n = 1, T SUM_UNITY = 0) {
    parent.resize(n);
    rank.resize(n);
    diff_weight.resize(n);
    for (int i = 0; i < n; ++i)
      parent[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
  }
  int find(int x) {
    if (parent[x] == x) return x;
    diff_weight[x] += diff_weight[parent[x]];
    return parent[x] = find(parent[x]);
  }
  bool unite(int x, int y, T w) {
    w += weight(x);
    w -= weight(y);
    x = find(x);
    y = find(y);
    if (x == y) return false;
    if (rank[x] < rank[y]) swap(x, y), w = -w;
    if (rank[x] == rank[y]) ++rank[x];
    parent[y] = x;
    diff_weight[y] = w;
    return true;
  }
  T weight(int x) {
    find(x);
    return diff_weight[x];
  }
  T diff(int x, int y) { return weight(y) - weight(x); }
  bool same(int x, int y) { return find(x) == find(y); }
};
signed main() {
  int N, M;
  MACRO_VAR_Scan(N, M);
  ;
  UnionFind_Weight<int> uf(N);
  for (long long i = long long(0); i < long long(M); ++i) {
    int l, r, d;
    MACRO_VAR_Scan(l, r, d);
    ;
    --l, --r;
    if (uf.same(l, r)) {
      if (uf.diff(l, r) != d) return Yes(0);
    } else {
      uf.unite(l, r, d);
    }
  }
  Yes(1);
}
