#include <bits/stdc++.h>
using namespace std;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
void c1() {
  int n;
  cin >> n;
  vector<vector<int> > v;
  vector<vector<int> > m;
  v.resize(2);
  m.resize(2);
  int tmp;
  v[0].resize(n);
  v[1].resize(n);
  m[0].resize(n);
  m[1].resize(n);
  bool flg;
  for (int i = 0; i < (n); i++) {
    cin >> tmp;
    v[0][i] = tmp;
  }
  for (int i = 0; i < (n); i++) {
    cin >> tmp;
    v[1][i] = tmp;
  }
  int res = 0;
  m[0][0] = v[0][0];
  for (int i = (1); i < (n); i++) {
    m[0][i] = m[0][i - 1] + v[0][i];
  }
  m[1][0] = v[1][0] + v[0][0];
  for (int i = (1); i < (n); i++) {
    m[1][i] = v[1][i] + max(m[0][i], m[1][i - 1]);
  }
  if (n == 1) {
    cout << v[1][0] + v[0][0] << endl;
  } else {
    cout << m[1][n - 1] << endl;
  }
}
void c2() {
  int n, m;
  cin >> n >> m;
  int li, ri, di;
  vector<vector<int> > h;
  h.resize(m);
  for (int i = 0; i < (m); i++) {
    h[i].resize(3);
  }
  for (int i = 0; i < (m); i++) {
    cin >> li >> ri >> di;
    h[i][0] = li - 1;
    h[i][1] = ri - 1;
    h[i][2] = di;
  }
  bool flg = true;
  int li2, ri2, di2, li3, ri3, di3, tmp2, tmp3;
  int b1, b2, b3;
  int wdi[3];
  for (int i = 0; i < (m); i++) {
    if (flg == false) {
      break;
    }
    ri = h[i][0];
    li = h[i][1];
    di = h[i][2];
    for (int j = 0; j < (m); j++) {
      if (flg == false) {
        break;
      }
      if (i == j) {
        continue;
      }
      ri2 = h[j][0];
      li2 = h[j][1];
      di2 = h[j][2];
      if (li == li2) {
        tmp3 = ri2;
        tmp2 = ri;
      } else if (li == ri2) {
        tmp3 = li2;
        tmp2 = ri;
      } else if (ri == li2) {
        tmp3 = ri2;
        tmp2 = li;
      } else if (ri == ri2) {
        tmp3 = li2;
        tmp2 = li;
      } else {
        continue;
      }
      for (int k = 0; k < (m); k++) {
        if (j == k || i == k) {
          continue;
        }
        ri3 = h[k][0];
        li3 = h[k][1];
        di3 = h[k][2];
        if ((li3 == tmp3 && ri3 == tmp2) || (ri3 == tmp3 && li3 == tmp2)) {
          if (li == li2) {
            b1 = 3;
            if (ri == li3) {
              b2 = 1;
              b3 = 2;
            } else {
              b2 = 2;
              b3 = 1;
            }
          } else if (li == li3) {
            b1 = 2;
            if (ri == li2) {
              b2 = 1;
              b3 = 3;
            } else {
              b2 = 3;
              b3 = 1;
            }
          } else if (li2 == li3) {
            b1 = 1;
            if (ri2 == li) {
              b2 = 2;
              b3 = 3;
            } else {
              b2 = 3;
              b3 = 2;
            }
          } else {
            flg = false;
            cout << "No" << endl;
            break;
          }
          wdi[0] = di;
          wdi[1] = di2;
          wdi[2] = di3;
          if (wdi[b1 - 1] + wdi[b2 - 1] == wdi[b3 - 1]) {
            flg = true;
          } else {
            flg = false;
            cout << "No" << endl;
            break;
          }
        }
      }
    }
  }
  if (flg) {
    cout << "Yes" << endl;
  }
}
void c3() { int s = 3; }
int main() { c2(); }
