#include <bits/stdc++.h>
using namespace std;
const long long INF = 2000000000;
const long long INF2 = 8000000000000000000;
const long long large_P = 1000000007;
long long my_pow(long long N, long long a, long long M) {
  long long tempo;
  if (a == 0) {
    return 1;
  } else {
    if (a % 2 == 0) {
      tempo = my_pow(N, a / 2, M);
      return (tempo * tempo) % M;
    } else {
      tempo = my_pow(N, a - 1, M);
      return (tempo * N) % M;
    }
  }
}
long long my_combination(long long N, long long a, long long M) {
  long long answer = 1;
  for (long long i = 0; i < (a); i++) {
    answer *= (N - i);
    answer %= M;
  }
  for (long long i = 0; i < (a); i++) {
    answer *= my_pow(i + 1, M - 2, M);
    answer %= M;
  }
  return answer;
}
long long my_gcd(long long& a, long long& b) {
  if (b == 0) return a;
  long long temp = a % b;
  return my_gcd(b, temp);
}
void ll_to_vector(long long base, long long n, vector<long long>& v) {
  long long tempo = n;
  long long tempo2 = n;
  long long n_digit = 1;
  while (tempo2 >= 10) {
    tempo2 /= 10;
    n_digit++;
  }
  v.assign(n_digit, 0);
  for (long long i = 0; i < n_digit; i++) {
    v.at(i) = tempo / pow(base, n_digit - 1 - i);
    tempo -= v.at(i) * pow(base, n_digit - 1 - i);
  }
}
long long char_to_int(char c) {
  switch (c) {
    case '0':
      return 0;
    case '1':
      return 1;
    case '2':
      return 2;
    case '3':
      return 3;
    case '4':
      return 4;
    case '5':
      return 5;
    case '6':
      return 6;
    case '7':
      return 7;
    case '8':
      return 8;
    case '9':
      return 9;
    default:
      return 0;
  }
}
void prime_judge(vector<bool>& prime_or_not) {
  prime_or_not.at(0) = false;
  prime_or_not.at(1) = false;
  long long n = prime_or_not.size() - 1;
  long long region = (long long)pow((long double)(n), 0.50) + 1;
  for (long long i = 2; i <= n / 2; i++) {
    prime_or_not.at(2 * i) = false;
  }
  for (long long i2 = 1; i2 < n / 2; i2++) {
    long long i = 2 * i2 + 1;
    if (i < region && prime_or_not.at(i)) {
      long long j = i * i;
      while (j < n + 1) {
        prime_or_not.at(j) = false;
        j += 2 * i;
      }
    }
  }
};
map<long long, long long> divide_to_prime(long long target) {
  map<long long, long long> res;
  long long upper_lim = ceil(pow((long double)(target), 0.50));
  vector<bool> prime_or_not(upper_lim + 1, true);
  if (upper_lim < 20) prime_or_not.assign(25, true);
  prime_judge(prime_or_not);
  long long tempo = target;
  for (long long i = 0; i < ((upper_lim + 1)); i++) {
    if (prime_or_not.at(i)) {
      while (tempo % i == 0) {
        tempo /= i;
        res[i]++;
      }
    }
  }
  if (tempo != 1) res[tempo]++;
  return res;
}
void BFS_labyrinth(queue<pair<long long, long long>>& que,
                   vector<vector<long long>>& dist, long long& area) {
  long long n = dist.size();
  long long m = dist.at(0).size();
  while (!que.empty()) {
    long long temp_i, temp_j;
    pair<long long, long long> tempo = que.front();
    que.pop();
    temp_i = tempo.first;
    temp_j = tempo.second;
    for (long long i = -1; i <= 1; i++) {
      for (long long j = -1; j <= 1; j++) {
        if (temp_i + i < 0 || n <= temp_i + i) continue;
        if (temp_j + j < 0 || m <= temp_j + j) continue;
        if (i == 0 && j == 0) continue;
        if (i * j != 0) continue;
        if (dist.at(temp_i + i).at(temp_j + j) != -1) continue;
        dist.at(temp_i + i).at(temp_j + j) = dist.at(temp_i).at(temp_j) + 1;
        que.push(make_pair(temp_i + i, temp_j + j));
      }
    }
    if (que.empty()) {
      for (long long i = 0; i < (n); i++) {
        for (long long j = 0; j < (m); j++) {
          if (dist.at(i).at(j) == -1) {
            que.push(make_pair(i, j));
            dist.at(i).at(j) = 0;
            area++;
            break;
          }
        }
        if (!que.empty()) break;
      }
    }
  }
}
void dfs(const vector<vector<long long>> G, vector<bool>& seen, long long v) {
  seen.at(v) = true;
  for (long long next_v : G.at(v)) {
    if (seen.at(next_v)) continue;
    dfs(G, seen, next_v);
  }
}
class UnionFind {
 public:
  vector<long long> parent;
  vector<long long> rank;
  UnionFind(long long N) : parent(N), rank(N, 0) {
    for (long long i = 0; i < (N); i++) {
      parent.at(i) = i;
    }
  }
  long long root(long long x) {
    if (parent.at(x) == x) return x;
    return parent.at(x) = root(parent.at(x));
  }
  void unite(long long x, long long y) {
    long long rx = root(x);
    long long ry = root(y);
    if (rx == ry) return;
    if (rank.at(rx) < rank.at(ry)) {
      parent.at(rx) = ry;
    } else {
      parent.at(ry) = rx;
      if (rank.at(rx) == rank.at(ry)) rank.at(rx)++;
    }
  }
  bool same(long long x, long long y) { return (root(x) == root(y)); }
};
signed main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> L(M), R(M), D(M);
  for (long long i = 0; i < (M); i++) {
    cin >> L.at(i) >> R.at(i) >> D.at(i);
    L.at(i)--;
    R.at(i)--;
  }
  UnionFind tree(N);
  vector<long long> dist(N, -1);
  bool able = true;
  long long max_pos = 0;
  for (long long i = 0; i < (M); i++) {
    if (!tree.same(L.at(i), R.at(i))) {
      tree.unite(L.at(i), R.at(i));
      if (dist.at(L.at(i)) == -1 && dist.at(R.at(i)) == -1) {
        dist.at(R.at(i)) = D.at(i);
        dist.at(L.at(i)) = 0;
        if (max_pos < dist.at(R.at(i))) max_pos = dist.at(R.at(i));
      } else if (dist.at(L.at(i)) != -1) {
        dist.at(R.at(i)) = dist.at(L.at(i)) + D.at(i);
        if (max_pos < dist.at(R.at(i))) max_pos = dist.at(R.at(i));
      } else {
        dist.at(L.at(i)) = dist.at(R.at(i)) - D.at(i);
        if (dist.at(L.at(i)) < 0) {
          long long tempo = -dist.at(L.at(i));
          for (long long j = 0; j < (N); j++) {
            if (tree.same(L.at(i), j)) {
              dist.at(j) += tempo;
              if (max_pos < dist.at(j)) max_pos = dist.at(j);
            }
          }
        }
      }
    } else {
      if (dist.at(R.at(i)) - dist.at(L.at(i)) != D.at(i)) {
        able = false;
        break;
      }
    }
  }
  if (max_pos > 1e9) able = false;
  if (able)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
