#include <bits/stdc++.h>
using namespace std;
struct inf {
  int L;
  int R;
  int D;
  bool solve;
} a[200002];
struct xy {
  int s;
  bool nem;
} p[100001];
int N, M;
bool b1, b2, bm;
int main() {
  bm = true;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> a[i].L;
    cin >> a[i].R;
    cin >> a[i].D;
  }
  while (!b2) {
    if (!bm) break;
    if (b1) {
      b1 = false;
      for (int i = 0; i < M; i++) {
        if (!a[i].solve) {
          if (p[a[i].L].nem) {
            if (p[a[i].R].nem) {
              if (p[a[i].R].s - p[a[i].L].s != a[i].D) {
                bm = false;
                break;
              }
            } else {
              p[a[i].R].s = p[a[i].L].s + a[i].D;
              p[a[i].R].nem = true;
              b1 = true;
              a[i].solve = true;
              break;
            }
          } else {
            if (p[a[i].R].nem) {
              p[a[i].L].s = p[a[i].R].s - a[i].D;
              p[a[i].L].nem = true;
              b1 = true;
              a[i].solve = true;
              break;
            }
          }
        }
      }
    } else {
      for (int i = 0; i < M; i++) {
        if (!a[i].solve) {
          p[a[i].L].nem = true;
          b1 = true;
          break;
        }
      }
      if (!b1) b2 = true;
    }
  }
  if (bm)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
