#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
vector<pair<int, int> > e[maxn];
long long dis[maxn];
bool vis[maxn];
int n, m, flag = 0;
void dfs(int x) {
  vis[x] = 1;
  for (int i = 0; i < e[x].size(); i++) {
    pair<int, int> cur = e[x][i];
    if (vis[cur.first]) {
      if (dis[cur.first] - dis[x] != cur.second) {
        flag = 1;
        break;
      }
    } else {
      dis[cur.first] = dis[x] + cur.second;
      dfs(cur.first);
    }
  }
}
int main() {
  cin >> n >> m;
  memset(vis, 0, sizeof(vis));
  for (int i = 0; i < m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    e[l].push_back({r, d});
    e[r].push_back({l, -d});
  }
  flag = 0;
  for (int i = 0; i < n; i++) {
    if (!vis[i]) dfs(i);
    if (flag) {
      break;
    }
  }
  if (flag) {
    cout << "No" << endl;
  } else
    cout << "Yes" << endl;
  return 0;
}
