#include <bits/stdc++.h>
using namespace std;
const long long mod = int(1e9) + 7;
long long x[100001];
vector<pair<int, int> > adj[100001];
long long mini, maxi;
int n, m;
struct UnionFind {
  vector<int> depth, parent;
  UnionFind(int N) {
    depth.assign(N, 0);
    parent.assign(N, 0);
    fill(parent.begin(), parent.end(), 0);
  }
  int findParent(int i) {
    if (parent[i] == i) return i;
    return parent[i] = findParent(parent[i]);
  }
  void join(int i, int j) {
    i = findParent(i);
    j = findParent(j);
    if (i == j) return;
    if (depth[i] < depth[j]) swap(i, j);
    parent[j] = i;
    depth[i] = max(depth[i], depth[j] + 1);
  }
};
bool done[100001];
void dfs(int i, long long y) {
  if (done[i]) return;
  mini = min(y, mini);
  maxi = max(y, maxi);
  x[i] = y;
  done[i] = 1;
  for (auto v : adj[i]) {
    dfs(v.first, y + v.second);
  }
}
bool check() {
  for (int i = 0; i < n; i++) {
    for (pair<int, int> p : adj[i]) {
      if ((x[p.first] - x[i]) != p.second) return false;
    }
  }
  return true;
}
int main() {
  cin >> n >> m;
  UnionFind u = UnionFind(n);
  int i = 0;
  for (int i = 0; i < int(m); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    adj[a].push_back(make_pair(b, c));
    adj[b].push_back(make_pair(a, -c));
    u.join(a, b);
  }
  for (int i = 0; i < int(n); i++) {
    if (u.parent[i] == i) {
      mini = 1e9;
      maxi = -1e9;
      dfs(i, 0);
      if (abs(maxi - mini) > 1e9) {
        cout << "No";
        return 0;
      }
    }
  }
  if (check())
    cout << "Yes";
  else
    cout << "No";
}
