#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LINF = 1e18;
using namespace std;
void CINT() {}
template <class Head, class... Tail>
void CINT(Head&& head, Tail&&... tail) {
  cin >> head;
  CINT(move(tail)...);
}
class UnionFind {
 public:
  vector<int> par, rank;
  UnionFind(int n);
  int Find(int x);
  void Unite(int x, int y);
  bool Same(int x, int y);
};
UnionFind::UnionFind(int n) {
  par.resize(n);
  rank.resize(n);
  for (int i = 0; i < (n); ++i) {
    par[i] = i;
    rank[i] = 0;
  }
}
int UnionFind::Find(int x) { return (par[x] == x ? x : Find(par[x])); }
void UnionFind::Unite(int x, int y) {
  x = Find(x);
  y = Find(y);
  if (x == y) return;
  if (rank[x] < rank[y])
    par[x] = y;
  else {
    par[y] = x;
    if (rank[x] == rank[y]) rank[x]++;
  }
}
bool UnionFind::Same(int x, int y) { return (Find(x) == Find(y)); }
int n, m;
map<int, vector<int>> point_list;
map<int, vector<pair<pair<int, int>, int>>> edges;
bool Solve(int inp) {
  vector<int> l, r, d;
  vector<int> points = point_list[inp];
  for (int i = 0; i < (edges[inp].size()); ++i) {
    l.push_back(edges[inp][i].first.first);
    r.push_back(edges[inp][i].first.second);
    d.push_back(edges[inp][i].second);
  }
  map<int, long long> ps;
  queue<pair<pair<int, int>, int>> que;
  for (int i = 0; i < (l.size()); ++i)
    que.push(make_pair(make_pair(l[i], r[i]), d[i]));
  ps[que.front().first.first] = 0;
  ps[que.front().first.second] = que.front().second;
  que.pop();
  while (!que.empty()) {
    int long long = que.front().first.first;
    int rr = que.front().first.second;
    int range = que.front().second;
    que.pop();
    if (ps.count(long long) && ps.count(rr)) {
      if (ps[rr] - ps[long long] != range) return false;
    } else if (ps.count(long long) && !ps.count(rr)) {
      ps[rr] = ps[long long] + range;
    } else if (!ps.count(long long) && ps.count(rr)) {
      ps[long long] = ps[rr] - range;
    } else
      que.push(make_pair(make_pair(long long, rr), range));
  }
  return true;
}
int main() {
  cin >> n >> m;
  vector<int> l(m);
  vector<int> r(m);
  vector<int> d(m);
  for (int i = 0; i < (m); ++i) cin >> l[i] >> r[i] >> d[i];
  for (int i = 0; i < (m); ++i) {
    l[i]--;
    r[i]--;
  }
  UnionFind uni(n);
  for (int i = 0; i < (m); ++i) uni.Unite(l[i], r[i]);
  for (int i = 0; i < (n); ++i) point_list[uni.Find(i)].push_back(i);
  for (int i = 0; i < (m); ++i)
    edges[uni.Find(l[i])].push_back(make_pair(make_pair(l[i], r[i]), d[i]));
  for (auto&(xx) : (point_list))
    if (edges[xx.first].size() && !Solve(xx.first)) {
      cout << ((false) ? "Yes" : "No") << endl;
      return 0;
    }
  cout << ((true) ? "Yes" : "No") << endl;
  return 0;
}
