#include <bits/stdc++.h>
using namespace std;
struct UFNode {
  UFNode *parent;
  int height;
  int dist;
  UFNode() : parent(nullptr), height(1), dist(0) {}
  UFNode *getA() {
    if (parent == nullptr) {
      return this;
    } else {
      return parent->getA();
    }
  }
  int getD() {
    if (parent == nullptr) {
      return 0;
    } else {
      return dist + parent->getD();
    }
  }
};
int main(int argc, const char *argv[]) {
  int entityCount, queryCount;
  scanf("%d%d", &entityCount, &queryCount);
  UFNode uf[100000];
  for (int i = 0; i < queryCount; ++i) {
    int l, r, dist;
    scanf("%d%d%d", &l, &r, &dist);
    l--;
    r--;
    UFNode *pl, *pr;
    pl = uf[l].getA();
    pr = uf[r].getA();
    int dl = uf[l].getD();
    int dr = uf[r].getD();
    if (pl != pr) {
      if (pl->height > pr->height) {
        pl->parent = pr;
        pr->height = max(pr->height, pl->height + 1);
        pl->dist = -dl - dist + dr;
      } else {
        pr->parent = pl;
        pl->height = max(pl->height, pr->height + 1);
        pr->dist = dl + dist - dr;
      }
    } else {
      if (-dl + dr != dist) {
        printf("No\n");
        return 0;
      }
    }
  }
  printf("Yes\n");
  return 0;
}
