#include <bits/stdc++.h>
using namespace std;
int INF = (1LL << 30) - 1;
int MOD = 1e9 + 7;
vector<long long> x(100010);
vector<pair<int, int> > V[100010];
bool dfs(int t) {
  for (auto p : V[t]) {
    if (x[p.first]) {
      if (x[t] + p.second != x[p.first]) {
        return true;
      }
    } else {
      x[p.first] = x[t] + p.second;
      if (dfs(p.first)) return true;
    }
  }
  return false;
}
int main() {
  int N, M;
  cin >> N >> M;
  for (int i = int(0); i < int(M); ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    V[a].push_back(pair<int, int>(b, c));
    V[b].push_back(pair<int, int>(a, -c));
  }
  for (int i = int(0); i < int(N); ++i) {
    if (!x[i] && dfs(i)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}
