#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> adj[251002];
bool f;
bool visited[251002];
int pos[251002];
void dfs(int curr) {
  visited[curr] = true;
  for (pair<int, int> nxt : adj[curr]) {
    int w = nxt.second;
    if (!visited[nxt.first]) {
      dfs(nxt.first);
      int p1 = pos[nxt.first];
      if (pos[curr] == 0)
        pos[curr] = p1 - w;
      else if (p1 - w != pos[curr]) {
        cout << "No";
        f = true;
        exit;
      }
    } else {
      int p1 = pos[nxt.first];
      if (pos[curr] == 0)
        pos[curr] = p1 - w;
      else if (p1 - w != pos[curr]) {
        if (!f) cout << "No";
        f = true;
        exit;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int r, l, x;
    cin >> l >> r >> x;
    adj[l].push_back(make_pair(r, x));
  }
  for (int i = 1; i <= n; i++)
    if (!visited[i]) dfs(i);
  for (int i = 0; i < n; i++)
    for (pair<int, int> nx : adj[i]) {
      int l = i;
      int r = nx.first;
      if (pos[r] - pos[l] != nx.second) {
        cout << "No";
        return 0;
      }
    }
  if (!f) cout << "Yes";
  return 0;
}
