#include <bits/stdc++.h>
const int N = 100001;
int n, m;
struct edge {
  int to, weight;
};
struct node {
  edge e;
  node *next;
};
node nodes[4 * N];
int currentCount = 0;
node *edges[N];
int p[N];
int count[N];
int distancePeople[N];
void addEdge(int from, int to, int weight) {
  edge e;
  e.to = to;
  e.weight = weight;
  node *nod = nodes + currentCount++;
  nod->e = e;
  nod->next = edges[from];
  edges[from] = nod;
}
int getPart(int x) { return p[x]; }
void init() {
  for (int i = 0; i < N; i++) {
    p[i] = i;
    count[i] = 1;
  }
}
void DFS(int x, int d, int initialDistancePeople, int part) {
  distancePeople[x] = initialDistancePeople + d;
  p[x] = part;
  count[part]++;
  for (node *pp = edges[x]; pp; pp = pp->next) {
    edge ed = pp->e;
    if (p[ed.to] != part) {
      DFS(ed.to, ed.weight, distancePeople[x], part);
    }
  }
}
void unite(int x, int y, int d) {
  if (count[x] > count[y]) {
    DFS(y, d, distancePeople[x], getPart(x));
  } else {
    DFS(x, -d, distancePeople[y], getPart(y));
  }
  addEdge(x, y, d);
  addEdge(y, x, -d);
}
bool checkDistancePeople(int x, int y, int d) {
  return (distancePeople[y] - distancePeople[x]) == d;
}
int main() {
  init();
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int x, y, d;
    scanf("%d%d%d", &x, &y, &d);
    if (getPart(x) != getPart(y)) {
      unite(x, y, d);
    } else {
      if (!checkDistancePeople(x, y, d)) {
        printf("No\n");
        return 0;
      } else {
        addEdge(x, y, d);
        addEdge(y, x, -d);
      }
    }
  }
  printf("Yes\n");
  return 0;
}
