#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using edge = struct { ll to, cost; };
const ll inf = 1ll << 60ll;
vector<vector<edge>> graph(100005);
vector<ll> x(100005, inf);
vector<vector<bool>> color(100005, vector<bool>(100005, false));
ll n, m;
bool dfs(ll node, ll pos);
int main() {
  ll l, r, d;
  bool f = true;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> l >> r >> d;
    graph[l].push_back((edge){r, d});
    graph[r].push_back((edge){l, -d});
    color[l][r] = true;
    color[r][l] = true;
  }
  for (int i = 1; i <= n; i++) {
    if (x[i] == inf) {
      f &= dfs(i, 0);
    }
  }
  cout << (f ? "Yes" : "No") << endl;
}
bool dfs(ll node, ll pos) {
  if (x[node] == inf) {
    x[node] = pos;
  } else if (x[node] != pos) {
    return false;
  }
  bool res = true;
  for (int i = 0; i < graph[node].size(); i++) {
    if (color[node][graph[node][i].to]) {
      color[node][graph[node][i].to] = false;
      res &= dfs(graph[node][i].to, pos + graph[node][i].cost);
    }
  }
  return res;
}
