#include <bits/stdc++.h>
using namespace std;
const int CMax = 100002;
int n, m, l, r, d, ats;
long long sk;
set<pair<int, pair<int, int> > > S, S1;
set<pair<int, pair<int, int> > >::iterator it;
pair<int, pair<int, int> > pap;
set<long long> A[CMax];
set<long long>::iterator ait;
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d %d %d", &l, &r, &d);
    S.insert(make_pair(min(l, r), make_pair(max(l, r), d)));
  }
  for (it = S.begin(); it != S.end(); ++it) {
    pap = *it;
    l = pap.first;
    r = pap.second.first;
    d = pap.second.second;
    if (it == S.begin()) {
      A[l].insert(0);
      A[r].insert((long long)(0 - d));
      A[r].insert((long long)d);
    } else if (A[l].size() == 0 && A[r].size() == 0) {
      S1.insert(pap);
    } else if (A[l].size() > 0 && A[r].size() == 0) {
      for (ait = A[l].begin(); ait != A[l].end(); ++ait) {
        sk = *ait;
        A[r].insert(sk - d);
        A[r].insert(sk + d);
      }
    } else if (A[l].size() == 0 && A[r].size() > 0) {
      for (ait = A[r].begin(); ait != A[r].end(); ++ait) {
        sk = *ait;
        A[l].insert(sk - d);
        A[l].insert(sk + d);
      }
    } else {
      bool tik = false;
      for (ait = A[l].begin(); ait != A[l].end(); ++ait) {
        sk = *ait;
        if (A[r].find(sk - d) != A[r].end() || A[r].find(sk + d) != A[r].end())
          tik = true;
      }
      if (!tik) {
        printf("No\n");
        return 0;
      }
    }
  }
  for (it = S1.begin(); it != S1.end(); ++it) {
    pap = *it;
    l = pap.first;
    r = pap.second.first;
    d = pap.second.second;
    if (A[l].size() == 0 && A[r].size() == 0) {
    } else if (A[l].size() > 0 && A[r].size() == 0) {
      for (ait = A[l].begin(); ait != A[l].end(); ++ait) {
        sk = *ait;
        A[r].insert(sk - d);
        A[r].insert(sk + d);
      }
    } else if (A[l].size() == 0 && A[r].size() > 0) {
      for (ait = A[r].begin(); ait != A[r].end(); ++ait) {
        sk = *ait;
        A[l].insert(sk - d);
        A[l].insert(sk + d);
      }
    } else {
      bool tik = false;
      for (ait = A[l].begin(); ait != A[l].end(); ++ait) {
        sk = *ait;
        if (A[r].find(sk - d) != A[r].end() || A[r].find(sk + d) != A[r].end())
          tik = true;
      }
      if (!tik) {
        printf("No\n");
        return 0;
      }
    }
  }
  printf("Yes\n");
}
