#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > l_list[100005];
int check[100005];
int d[100005];
int DFS(int x, int ct) {
  check[x] = ct == 1000000007 ? 1 : 2;
  d[x] = ct;
  for (auto &p : l_list[x]) {
    if (check[p.first] == 1)
      continue;
    else if (check[p.first] == 2) {
      if (d[x] == 1000000007) {
        d[x] = d[p.first] - p.second;
        check[x] = 2;
      } else {
        if (d[x] != d[p.first] - p.second) return -1000000007;
      }
    } else {
      if (check[x] < 2) {
        int t = DFS(p.first, 1000000007);
        if (t == -1000000007) return -1000000007;
        if (d[x] == 1000000007) {
          d[x] = t - p.second;
          check[x] = 2;
        } else {
          if (d[x] != t - p.second) return -1000000007;
        }
      } else {
        int t = DFS(p.first, ct + p.second);
        if (t == -1000000007) return -1000000007;
      }
    }
  }
  if (d[x] == 1000000007) d[x] = 0, check[x] = 2;
  return d[x];
}
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < k; i++) {
    int t1, t2, t;
    scanf("%d%d%d", &t1, &t2, &t);
    l_list[t1].push_back({t2, t});
    l_list[t2].push_back({t1, -t});
  }
  for (int i = 1; i <= n; i++) {
    if (!check[i]) {
      if (DFS(i, 1000000007) == -1000000007) return printf("No"), 0;
    }
  }
  printf("Yes");
}
