#include int main() { using namespace std; unsigned N, A, B; cin >> N >> A >> B; vector X(N + 1), Y(N + 1), K(N + 1); for (unsigned i{1}; i <= N; ++i) { int x, y; cin >> x >> y >> K[i]; X[i] = x + 1000; Y[i] = y + 1000; } vector> edges(256); for (unsigned i{1}; i <= N; ++i) edges[0].emplace_back(i); // (-, -) -> (i, -) for (unsigned i{1}; i <= N; ++i) for (unsigned j{1}; j <= N; ++j) if (i != j) if (B + min(K[i], K[j]) <= max(K[i], K[j]) || A + min(X[i], X[j]) + min(Y[i], Y[j]) <= max(X[i], X[j]) + max(Y[i], Y[j])) edges[i * 16].emplace_back(j); // (i, -) -> (j, i) for (unsigned i{1}; i <= N; ++i) for (unsigned j{1}; j <= N; ++j) if (i != j) for (unsigned k{1}; k <= N; ++k) if (i != k && j != k) if (B + min(K[j], K[k]) <= max(K[j], K[k]) || A + min(X[i], X[k]) + min(Y[i], Y[k]) + min(X[j], X[k]) + min(Y[j], Y[k]) <= max(X[i], X[k]) + max(Y[i], Y[k]) + max(X[j], X[k]) + max(Y[j], Y[k])) edges[j * 16 + i].emplace_back(k); // (j, i) -> (k, j) vector dp(256U << N); const auto access{[&dp](unsigned visited, unsigned p_1, unsigned p_2) -> unsigned & { return dp[visited * 256 + p_1 * 16 + p_2]; }}; access(0, 0, 0) = 1; unsigned ans{}; for (unsigned i{}; i < 1U << N; ++i) for (unsigned j{}; j <= N; ++j) for (unsigned k{}; k <= N; ++k) if (access(i, j, k)) { for (const auto nexts : edges[j * 16 + k]) access(i | ((1 << nexts) / 2), nexts, j) = 1; ans = max(ans, popcount(i)); } cout << ans << endl; return 0; }