#include #include using namespace std; using namespace atcoder; typedef modint998244353 mint; typedef long long ll; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--) template bool chmin(T &a, const T &b) { if (a <= b) return false; a = b; return true; } template bool chmax(T &a, const T &b) { if (a >= b) return false; a = b; return true; } bool hav[15]; ll x[15], y[15], k[15]; ll a, b; int n; vector tr; int tar = 0; ll dist(int i, int j){ if (i == n) return 0; if (j == n) return 1e18; return abs(x[i] - x[j]) + abs(y[i] - y[j]); } ll kdist(int i, int j){ if (i == n) return 1e18; if (j == n) return 1e18; return abs(k[i] - k[j]); } int main(){ cin >> n >> a >> b; rep(i,0,n){ cin >> x[i] >> y[i] >> k[i]; } vector dp(1<(n+1))); dp[0][n][n] = true; rep(i,0,1<> l & 1) == 0){ if (a <= dist(l, k) + dist(j, l) || b <= kdist(l, k)){ dp[i|(1<