#include <bits/stdc++.h>
using namespace std;
int n, m, a, b, dif, mp[100005], mn = (int)2e9, mx = (int)-2e9;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &a, &b, &dif);
    if (mp[a] != 0 && mp[b] != 0) {
      if (mp[b] - mp[a] != dif) {
        printf("No\n");
        return 0;
      }
    } else if (mp[a] == 0 && mp[b] != 0) {
      mp[a] = mp[b] - dif;
    } else if (mp[a] != 0 && mp[b] == 0) {
      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;
}
