#include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 30);
const long long inf = (1LL << 60LL);
const int MAXN = 1e6 + 5;
int n, m;
struct node {
  int l, r;
  long long D;
  node() {}
  node(int _l, int _r, long long _D) {
    l = _l;
    r = _r;
    D = _D;
  }
  bool operator<(const node &a) const { return D < a.D; }
};
node v[200005];
long long arr[200005];
int main(int argc, const char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> v[i].l >> v[i].r >> v[i].D;
  }
  sort(v, v + m);
  memset(arr, -1, sizeof arr);
  int l, r;
  for (int i = 0; i < m; i++) {
    l = v[i].l - 1;
    r = v[i].r - 1;
    if (arr[l] == -1 && arr[r] == -1) {
      arr[r] = v[i].D;
      arr[l] = 0;
    } else if (arr[l] != -1 && arr[r] == -1) {
      arr[r] = arr[l] + v[i].D;
    } else if (arr[l] == -1 && arr[r] != -1) {
      if (arr[r] - v[i].D >= 0) {
        arr[l] = arr[r] - v[i].D;
      } else {
        return 0 * printf("No\n");
      }
    } else {
      if (arr[r] - arr[l] == v[i].D) {
        continue;
      }
      return 0 * printf("No\n");
    }
  }
  printf("Yes\n");
  return 0;
}
