#include <bits/stdc++.h>
using namespace std;
struct node {
  int y, cost;
  bool operator<(node d) const { return cost < d.cost; }
} drg[105];
int n, m, dst[105];
bool ans;
vector<node> net[105];
void dfs(int x) {
  int sz = net[x].size();
  node y;
  while (sz--) {
    y = net[x][sz];
    if (dst[y.y]) {
      if (dst[x] + y.cost != dst[y.y]) ans = true;
      continue;
    }
    dst[y.y] = dst[x] + y.cost;
    dfs(y.y);
  }
}
int main() {
  int i, x;
  node p;
  scanf("%d %d", &n, &m);
  for (i = 1; i <= n; i++) drg[i].y = i;
  for (i = 0; i < m; i++) {
    scanf("%d %d %d", &x, &p.y, &p.cost);
    net[x].push_back(p);
    drg[p.y].cost++;
  }
  sort(drg + 1, drg + n + 1);
  for (i = 1; i <= n; i++) {
    if (dst[drg[i].y]) continue;
    dst[drg[i].y] = 1;
    dfs(drg[i].y);
  }
  printf("%s\n", (ans) ? "No" : "Yes");
  return 0;
}
