#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 10;
int l[MAX], r[MAX], d[MAX];
vector<int> adj[MAX], edg[MAX];
bool vis[MAX];
int cnt[MAX];
void dfs(int v) {
  vis[v] = true;
  for (int i = (int)(0); i < (int)(adj[v].size()); i++) {
    int u = adj[v][i];
    if (vis[u] && (cnt[u] != edg[v][i] + cnt[v])) {
      cout << "No";
      exit(0);
    }
    if (!vis[u]) {
      cnt[u] = cnt[v] + edg[v][i];
      dfs(u);
    }
  }
}
int n, m;
int main() {
  cin >> n >> m;
  for (int i = (int)(1); i < (int)(m + 1); i++) {
    cin >> l[i] >> r[i] >> d[i];
    adj[l[i]].push_back(r[i]);
    adj[r[i]].push_back(l[i]);
    edg[l[i]].push_back(d[i]);
    edg[r[i]].push_back(-d[i]);
  }
  for (int i = (int)(1); i < (int)(n + 1); i++) {
    if (!vis[n]) dfs(i);
  }
  cout << "Yes" << endl;
  return 0;
}
