#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T> class DisjointSet {
public:
  vector<T> rank, p;
  DisjointSet() {}
  DisjointSet(int size) {
    rank.resize(size, 0);
    p.resize(size, 0);
    rep(i, 0, size) makeSet(i);
  }
  void makeSet(int x) {
    p[x] = x;
    rank[x] = 0;
  }
  bool same(int x, int y) { return findSet(x) == findSet(y); }
  void unite(int x, int y) { link(findSet(x), findSet(y)); }
  void link(int x, int y) {
    if (rank[x] > rank[y]) {
      p[y] = x;
    } else {
      p[x] = y;
      if (rank[x] == rank[y]) {
        rank[y]++;
      }
    }
  }
  int findSet(int x) {
    if (x != p[x]) {
      p[x] = findSet(p[x]); // path compression
    }
    return p[x];
  }
};

struct info {
  int l, r, d;
  info(int l, int r, int d) : l(l), r(r), d(d) {}
  bool operator<(info &o) {
    return (l != o.l ? l < o.l : (r != o.r ? r < o.r : (d < o.d)));
  }
};
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;
  vector<info> v;
  rep(i, 0, M) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    if (a > b) {
      swap(a, b);
      c *= -1;
    }
    v.push_back(info(a, b, c));
  }
  sort(all(v));

  map<int, int> m, inv;
  rep(i, 0, M) {
    int l = v[i].l, r = v[i].r, d = v[i].d;

    if (!m.count(l) and !m.count(r)) {
      m[l] = 0;
      m[r]=d;
      inv[0] = l;
      inv[d]=r;
    }
    else if(!m.count(l)){
      m[l]=m[r]-d;
      inv[m[r]-d]=l;
    }
    else if(!m.count(r)){
      m[r]=m[l]+d;
      inv[m[l]+d]=r;
    }
    else{
      if(m[l]+d!=m[r]){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;

  return 0;
}
