#ifdef DEBUG #include"stdlibrary.h" #else #pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include using namespace std; #endif // #include // #include // #include // using namespace __gnu_pbds; // #include // namespace multiprecisioninteger = boost::multiprecision; // using cint=multiprecisioninteger::cpp_int; using ll=long long; using datas=std::pair; using ddatas=std::pair; using tdata=std::pair; using vec=std::vector; using mat=std::vector; using pvec=std::vector; using pmat=std::vector; // using llset=tree,rb_tree_tag,tree_order_statistics_node_update>; #define For(i,a,b) for(i=a;i<(ll)b;++i) #define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i) #define rep(i,N) For(i,0,N) #define rep1(i,N) For(i,1,N) #define brep(i,N) bFor(i,N,0) #define brep1(i,N) bFor(i,N,1) #define all(v) std::begin(v),std::end(v) #define allr(v) std::rbegin(v),std::rend(v) #define vsort(v) std::sort(all(v)) #define vrsort(v) std::sort(allr(v)) #define uniq(v) vsort(v),(v).erase(std::unique(all(v)),std::end(v)) #define endl "\n" #define popcount __builtin_popcountll #define print(x) std::cout< std::ostream& operator<<(std::ostream& os,const T& v){return os< std::ostream& operator<<(std::ostream& os,const std::vector& v); template std::ostream& operator<<(std::ostream& os,const std::set& v); template std::ostream& operator<<(std::ostream& os,const std::multiset& v); template std::ostream& operator<<(std::ostream& os,const std::map& v); template std::ostream& operator<<(std::ostream& os,const std::pair& p){return os<<"("< std::ostream& operator<<(std::ostream& os,const std::vector& v){ os<<"{";bool f=false; for(auto& x:v){if(f)os<<",";os< std::ostream& operator<<(std::ostream& os,const std::set& v){ os<<"{";bool f=false; for(auto& x:v){if(f)os<<",";os< std::ostream& operator<<(std::ostream& os,const std::multiset& v){ os<<"{";bool f=false; for(auto& x:v){if(f)os<<",";os< std::ostream& operator<<(std::ostream& os,const std::map& v){ os<<"{";bool f=false; for(auto& x:v){if(f)os<<",";os< inline bool chmax(T& a,const T b){bool x=a inline bool chmin(T& a,const T b){bool x=a>b;if(x)a=b;return x;} #ifdef DEBUG void debugg(){std::cout<void debugg(const T& x,const Args&... args){std::cout<<" "<sync_with_stdio(0); cout<size;--i)modncrlistm[i-1]=modncrlistm[i]*i%mod; } return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod; } ll modpow(ll a,ll n,const ll m=mod){ if(n<0)return 0; ll res=1; while(n>0){ if(n&1)res=res*a%m; a=a*a%m; n>>=1; } return res; } constexpr ll gcd(const ll a,const ll b) noexcept{return (!b)?abs(a):(a%b==0)?abs(b):gcd(b,a%b);} constexpr ll lcm(const ll a,const ll b) noexcept{return a/gcd(a,b)*b;} // #include // using mint=atcoder::modint998244353; // void operator>>(istream& is,mint& v){long long x;is>>x;v=x;} ll solve(const vec& a){ ll N=a.size(); ll i,j,A=0; rep(i,N)chmax(A,a[i]); mat cnt(N+1,vec(A+1,0)); rep(i,N){ rep(j,A+1)cnt[i+1][j]=cnt[i][j]; cnt[i+1][a[i]]++; } ll ans=0; rep(i,N)rep(j,i){ ll K=a[j]-a[i]; if(K<=0||0>a[j]-K-10||a[i]+K+1>A)continue; ans+=cnt[j][a[j]-K-10]*(cnt[N][a[i]+K+1]-cnt[i+1][a[i]+K+1]); } return ans; } ll judge(const vec& a){ ll N=a.size(); ll i,j,k,l; ll ans=0; rep(l,N)rep(k,l)rep(j,k)rep(i,j){ ll K=a[j]-a[i]-10; if(a[k]==a[j]-K&&a[l]==a[k]+K+1)++ans; } return ans; } ll N,M,K,H,W,Q,A,B,C,D; string s,t; ll ans; int main(){ startupcpp(); // int codeforces;cin>>codeforces;while(codeforces--){ ll i,j; cin>>N>>A>>B; vector> v(N); for(auto&[x,y,k]:v){ cin>>x>>y>>k; } auto dist=[&](ll i,ll j){ auto[x1,y1,k1]=v[i]; auto[x2,y2,k2]=v[j]; return abs(x1-x2)+abs(y1-y2); }; vector dp(1<=A||abs(get<2>(v[i])-get<2>(v[j]))>=B){ dp[1<>k&1)continue; if(dist(j,k)+dist(i,k)>=A||abs(get<2>(v[j])-get<2>(v[k]))>=B){ dp[bit|1<