#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
int x[111111];
bool visit[111111];
int main() {
  int n, m, inf = 2000000000;
  scanf("%d%d", &n, &m);
  auto g = vector<vector<pair<int, int> > >(n);
  for (int i = (0); i < (m); ++i) {
    int l, r, d;
    scanf("%d%d%d", &l, &r, &d);
    l--, r--;
    g[l].push_back(make_pair(r, d));
    g[r].push_back(make_pair(l, -d));
  }
  queue<int> q;
  for (int i = (0); i < (n); ++i) {
    if (g[i].size() == 0 || visit[i]) continue;
    x[i] = 0;
    q.push(i);
    while (!q.empty()) {
      int idx = q.front();
      q.pop();
      for (int j = (0); j < (g[i].size()); ++j) {
        int ti = g[i][j].first;
        int td = g[i][j].second;
        if (visit[ti]) {
          if (x[ti] - x[idx] != td) {
            printf("No\n");
            return 0;
          }
        } else {
          visit[ti] = true;
          x[ti] = x[idx] + td;
          q.push(ti);
        }
      }
    }
  }
  printf("Yes\n");
  return 0;
}
