#include <bits/stdc++.h>
using namespace std;
int wari(int a, int b) {
  if (a % b == 0)
    return a / b;
  else
    return a / b + 1;
}
int keta(int a) {
  double b = a;
  b = log10(b);
  int c = b;
  return c + 1;
}
int souwa(int a) { return a * (a + 1) / 2; }
int lcm(int a, int b) {
  int d = a, e = b, f;
  if (a < b) swap(a, b);
  int c, m = 1;
  while (m) {
    c = a % b;
    if (c == 0) {
      f = b;
      m--;
    } else {
      a = b;
      b = c;
    }
  }
  return d * e / f;
}
int gcm(int a, int b) {
  int d = a, e = b, f;
  if (a < b) swap(a, b);
  int c, m = 1;
  while (m) {
    c = a % b;
    if (c == 0) {
      f = b;
      m--;
    } else {
      a = b;
      b = c;
    }
  }
  return f;
}
bool prime(int a) {
  if (a < 2)
    return false;
  else if (a == 2)
    return true;
  else if (a % 2 == 0)
    return false;
  double b = sqrt(a);
  for (int i = 3; i <= b; i += 2) {
    if (a % i == 0) {
      return false;
    }
  }
  return true;
}
signed main() {
  int a, b;
  cin >> a >> b;
  vector<pair<int, pair<int, int>>> c(b);
  for (int i = 0; i < b; i++) {
    cin >> c[i].first >> c[i].second.first >> c[i].second.second;
    c[i].first--;
    c[i].second.first--;
    if (c[i].first > c[i].second.first) {
      swap(c[i].first, c[i].second.first);
      c[i].second.second *= -1;
    }
  }
  sort(c.begin(), c.end());
  vector<pair<int, int>> d(a);
  for (int i = 0; i < a; i++) {
    d[i].first = 0;
    d[i].second = 0;
  }
  d[c[0].first].second = 1;
  string s = "Yes";
  for (int i = 0; i < b; i++) {
    int f = c[i].first, g = c[i].second.first, h = c[i].second.second;
    d[f].second = 1;
    if (d[g].second == 1 && d[g].first != d[f].first + h) {
      s = "No";
      break;
    }
    d[g].first = d[f].first + h;
    d[g].second = 1;
  }
  cout << s << endl;
}
