#include <bits/stdc++.h>
using namespace std;
int n, m;
long long x[100005];
struct co {
  int next, d;
  bool vis = false;
};
vector<co> v[100005];
bool dfs(int l, int r, int d) {
  if (x[l] == -100000000000 && x[r] == -100000000000)
    x[l] = 0, x[r] = d;
  else if (x[r] == -100000000000)
    x[r] = x[l] + d;
  else if (x[l] == -100000000000)
    x[l] = x[r] - d;
  else {
    if (x[l] + d != x[r]) {
      return false;
    }
  }
  int sz = v[r].size();
  for (int i = 0; i < sz; i++) {
    if (!v[r][i].vis) {
      v[r][i].vis = true;
      if (!dfs(r, v[r][i].next, v[r][i].d)) return false;
    }
  }
  return true;
}
void init() {
  for (int i = 1; i <= n; i++) x[i] = -100000000000;
}
int main() {
  scanf("%d%d", &n, &m);
  init();
  int _x;
  co tmp;
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &_x, &tmp.next, &tmp.d);
    v[_x].push_back(tmp);
    swap(tmp.next, _x);
    tmp.d *= -1;
    v[_x].push_back(tmp);
  }
  bool ans = true;
  for (int i = 1; i <= n; i++) {
    int sz = v[i].size();
    for (int j = 0; j < sz; j++) {
      v[i][j].vis = true;
      if (!dfs(i, v[i][j].next, v[i][j].d)) {
        ans = false;
        break;
      }
    }
    if (!ans) break;
  }
  if (ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
