#include <bits/stdc++.h>
using namespace std;
struct CustomGreater {
  bool operator()(const pair<int, int>& a, const pair<int, int>& b) const {
    if (a.first == b.first) {
      return a.second > b.second;
    }
    return a.first > b.first;
  }
};
struct Edge {
  int l;
  int r;
  long long int d;
};
static const int N_MAX = 100001;
int n;
int m;
typedef map<pair<int, int>, Edge*, CustomGreater> ME;
typedef vector<Edge*> VE;
vector<Edge*> l_map[N_MAX];
vector<Edge*> r_map[N_MAX];
ME lr_map;
void add(Edge* e) {
  l_map[e->l].push_back(e);
  r_map[e->r].push_back(e);
  lr_map[pair<int, int>(e->l, e->r)] = e;
}
int main(int argc, char* argv[]) {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; ++i) {
    Edge* e = new Edge;
    scanf("%d %d %d", &e->l, &e->r, &e->d);
    ME::iterator itlr = lr_map.find(pair<int, int>(e->l, e->r));
    if (itlr != lr_map.end()) {
      if (itlr->second->d != e->d) {
        puts("No");
        return 0;
      }
      delete e;
      continue;
    }
    ME::iterator itrl = lr_map.find(pair<int, int>(e->r, e->l));
    if (itrl != lr_map.end()) {
      if (itrl->second->d != -e->d) {
        puts("No");
        return 0;
      }
      delete e;
      continue;
    }
    vector<Edge*> es;
    for (VE::iterator it = l_map[e->r].begin(); it != l_map[e->r].end(); ++it) {
      Edge* le = new Edge;
      le->l = e->l;
      le->r = (*it)->r;
      le->d = (*it)->d + e->d;
      es.push_back(le);
    }
    for (VE::iterator it = r_map[e->l].begin(); it != r_map[e->l].end(); ++it) {
      Edge* re = new Edge;
      re->l = (*it)->l;
      re->r = e->r;
      re->d = (*it)->d + e->d;
      es.push_back(re);
    }
    es.push_back(e);
    for (auto ee : es) {
      add(ee);
    }
  }
  puts("Yes");
}
