#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const int inf = INT_MAX;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int MAX_V = 1e5;
vector<pii> es[MAX_V];
int pos[MAX_V];
bool used[MAX_V], able;
void dfs(int now) {
  used[now] = true;
  for (auto &e : es[now]) {
    int to = e.first, d = e.second;
    if (pos[to] == inf) {
      pos[to] = pos[now] + d;
      dfs(to);
    } else if (pos[to] != pos[now] + d)
      able = false;
  }
}
int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int L, R, D;
    cin >> L >> R >> D;
    L--, R--;
    es[L].push_back(pii(R, D));
    es[R].push_back(pii(L, -D));
  }
  fill(used, used + N, false);
  fill(pos, pos + N, inf);
  pos[0] = 0;
  able = true;
  for (int i = 0; i < N; i++) {
    if (!used[i]) dfs(i);
  }
  if (able)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
