#include <bits/stdc++.h>
using namespace std;
struct node {
  int to, next;
  long long w;
} edge[200000 + 100];
bool flag;
int k;
int head[100010], visit[100010];
long long dis[100010];
void add_edge(int from, int to, long long weight) {
  edge[k].to = to;
  edge[k].w = weight;
  edge[k].next = head[from];
  head[from] = k++;
}
void init_spfa() {
  for (int i = 0; i <= 100005; i++) dis[i] = 1e15;
  memset(visit, 0, sizeof(visit));
  memset(head, -1, sizeof(head));
  k = 0;
  flag = true;
}
void SPFA_dfs(int u) {
  visit[u] = 1;
  for (int i = head[u]; i != -1; i = edge[i].next) {
    int to = edge[i].to;
    if (dis[u] + edge[i].w < dis[to]) {
      if (visit[to] || !flag) {
        flag = false;
        break;
      }
      dis[to] = dis[u] + edge[i].w;
      SPFA_dfs(to);
    }
  }
  visit[u] = 0;
}
bool SPFA(int n) {
  for (int i = 1; i <= n; i++) {
    SPFA_dfs(i);
    if (!flag) return flag;
  }
  return true;
}
int main() {
  int N, M;
  int l, r;
  long long d;
  while (scanf("%d%d", &N, &M) != EOF) {
    init_spfa();
    while (M--) {
      scanf("%d%d%lld", &l, &r, &d);
      add_edge(l, r, d);
      add_edge(r, l, -d);
    }
    if (SPFA(N))
      printf("Yes\n");
    else
      printf("No\n");
  }
}
