#include <bits/stdc++.h>
using namespace std;
double eps = 1e-5;
const int INF = 2e9 + 7;
const long long LINF = 9e18 + 7;
const int MAX = 1e9;
const int N = 1e5 + 7;
vector<pair<int, int>> g[N], t[N];
vector<pair<pair<int, int>, int>> e;
int ans[N], col[N];
bool st[N];
void dfs(int u, int w) {
  col[u] = 1;
  ans[u] = w;
  for (auto it : g[u]) {
    int v, i;
    tie(v, i) = it;
    if (!col[v]) {
      dfs(v, ans[u] + e[i].second);
      continue;
    }
    if (col[v] == 1) {
      cout << "No" << endl;
      exit(0);
    }
  }
  col[u] = 2;
  for (auto it : t[u]) {
    int v, i;
    tie(v, i) = it;
    if (!col[v]) {
      dfs(v, ans[u] - e[i].second);
    }
  }
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < (int)(m); ++i) {
    int x, y, w;
    scanf("%d %d %d", &x, &y, &w);
    x--, y--;
    g[x].emplace_back(y, i);
    t[y].emplace_back(x, i);
    e.push_back({{x, y}, w});
    st[y] = true;
  }
  for (int i = 0; i < (int)(n); ++i) {
    if (!col[i] && !st[i]) dfs(i, 0);
  }
  int mx = -INF, mn = INF;
  for (int i = 0; i < (int)(n); ++i) {
    mx = max(mx, ans[i]);
    mn = min(mn, ans[i]);
  }
  if (mx + (mn < 0 ? abs(mn) : 0) > MAX) {
    cout << "No" << endl;
    return 0;
  }
  for (int i = 0; i < (int)(m); ++i) {
    int u, v;
    tie(u, v) = e[i].first;
    if (ans[v] - ans[u] != e[i].second) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}
