#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int pre[maxn], other[maxn], last[maxn], cost[maxn];
long long dis[maxn];
int vis_dr[maxn];
int all = -1;
void build(int x, int y, long long w) {
  pre[++all] = last[x];
  last[x] = all;
  other[all] = y;
  cost[all] = w;
}
bool dfs(int x) {
  int dt = last[x];
  while (dt != -1) {
    int dr = other[dt];
    if (vis_dr[dr] == 0 && vis_dr[x] == 1) {
      vis_dr[dr] = 1;
      dis[dr] = dis[x] + cost[dt];
      if (!dfs(dr)) return false;
    } else if (vis_dr[dr] == 1 && vis_dr[x] == 1) {
      if (dis[dr] != dis[x] + cost[dt]) return false;
    }
    dt = pre[dt];
  }
  return true;
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  memset(last, -1, sizeof(last));
  for (int i = 1; i <= m; i++) {
    int x, y;
    long long w;
    scanf("%d %d %lld", &x, &y, &w);
    build(x, y, w);
    build(y, x, -w);
  }
  for (int i = 1; i <= n; i++) {
    if (vis_dr[i] == 0) {
      vis_dr[i] = 1;
      if (!dfs(i)) {
        dis[i] = 0;
        printf("No\n");
        return 0;
      }
    }
  }
  printf("Yes\n");
}
