#include <bits/stdc++.h>
using namespace std;
int n, m, a, b, mn = (int)2e9, mx = (int)-2e9;
long long mp[100005], dif;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n + 1; i++) mp[i] = (int)(1e18);
  for (int i = 0; i < m; i++) {
    scanf("%d%d%lld", &a, &b, &dif);
    if (mp[a] != (int)(1e18) && mp[b] != (int)(1e18)) {
      if (mp[b] - mp[a] != dif) {
        printf("No\n");
        return 0;
      }
    } else if (mp[a] == (int)(1e18) && mp[b] != (int)(1e18)) {
      mp[a] = mp[b] - dif;
    } else if (mp[a] != (int)(1e18) && mp[b] == (int)(1e18)) {
      mp[b] = mp[a] + dif;
    } else
      mp[a] = 50000000, mp[b] = dif + 50000000;
    if (max(mp[a], mp[b]) > mx) mx = max(mp[a], mp[b]);
    if (min(mp[a], mp[b]) < mn) mn = min(mp[a], mp[b]);
  }
  if (mx - mn > 1000000000)
    printf("No\n");
  else
    printf("Yes\n");
  return 0;
}
