#include <bits/stdc++.h>
using namespace std;
template <typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance(vec.begin(), itr);
  if (index != vec.size()) {
    return 1;
  } else {
    return 0;
  }
}
template <typename T>
T gcd(T a, T b) {
  if (b > 0) {
    return gcd(b, a % b);
  } else {
    return a;
  }
}
template <typename T>
T lcm(T a, T b) {
  T g = gcd(a, b);
  return a * b / g;
}
void clear(std::queue<pair<int, int> > &q) {
  std::queue<pair<int, int> > empty;
  std::swap(q, empty);
}
bool IsPrime(int num) {
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2) {
    if (num % i == 0) {
      return false;
    }
  }
  return true;
}
template <typename T>
std::vector<T> enum_div(T n) {
  std::vector<T> ret;
  for (T i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i != 1 && i * i != n) {
        ret.push_back(n / i);
      }
    }
  }
  return ret;
}
int N, M;
int main() {
  cin >> N >> M;
  bool used[N];
  long long x[N];
  for (int i = 0; i < N; i++) {
    used[i] = false;
    x[i] = 0;
  }
  vector<pair<int, pair<int, long long> > > mp;
  for (int i = 0; i < M; i++) {
    int L, R;
    long long d;
    cin >> L >> R >> d;
    if (L < R) {
      int tmp = R;
      R = L;
      L = tmp;
      d = -d;
    }
    mp.push_back(make_pair(L, make_pair(R, d)));
  }
  sort(mp.begin(), mp.end());
  for (int i = 0; i < M; i++) {
    int L = mp[i].first;
    pair<int, long long> p = mp[i].second;
    int R = p.first;
    long long d = p.second;
    if (!used[L] && !used[R]) {
      x[L] = 0;
      x[R] = d;
      used[L] = true;
      used[R] = true;
    } else if (used[L] && !used[R]) {
      x[R] = x[L] + d;
      used[R] = true;
    } else if (used[L] && used[R]) {
      if (x[L] + d != x[R]) {
        cout << "No" << endl;
        return 0;
      }
    } else {
      x[L] = x[R] - d;
      used[L] = true;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
