#include <cstdio>
using namespace std;

const int MAX_N = 1000005;
int fa[MAX_N], dis[MAX_N];

int find(int x) {
  if (fa[x] == x) return x;
  int par = find(fa[x]);
  dis[x] += dis[fa[x]];
  return fa[x] = par;
}


bool add(int L, int R, int D) {
  if (find(L) == find(R)) {
    if (dis[L] - dis[R] != -D) {
      puts("No");
      return 0;
    }
    return 1;
  }
  int faR = fa[R], faL = fa[L];
  fa[faR] = fa[faL];
  dis[faR] = dis[L] + D - dis[R];
  return 1;
}


int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) fa[i] = i;
	
  for (int i = 1; i <= m; ++i) {
    int L, R, D;
    scanf("%d%d%d", &L, &R, &D);
    if (!add(L, R, D)) {
      return 0;
    }
  }
  puts("Yes");
  return 0;
}


