from math import gcd from bisect import bisect_left, bisect_right from heapq import heappop, heappush from collections import defaultdict, deque, Counter import sys sys.setrecursionlimit(5*10**5) input = sys.stdin.readline # n <= 1<<60 以下くらい def popcnt(n): c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555) c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333) c = (c & 0x0f0f0f0f0f0f0f0f) + ((c >> 4) & 0x0f0f0f0f0f0f0f0f) c = (c & 0x00ff00ff00ff00ff) + ((c >> 8) & 0x00ff00ff00ff00ff) c = (c & 0x0000ffff0000ffff) + ((c >> 16) & 0x0000ffff0000ffff) c = (c & 0x00000000ffffffff) + ((c >> 32) & 0x00000000ffffffff) return c n, A, B = map(int, input().split()) ball = [list(map(int, input().split())) for i in range(n)] dp = [[[0]*(n+1) for i in range(n+1)] for i in range(1 << n)] for i in range(n): dp[1 << i][i][-1] = 1 def dist(i, j): xi, yi, ki = ball[i] xj, yj, kj = ball[j] return abs(xi-xj) + abs(yi-yj) def speed(i,j): xi, yi, ki = ball[i] xj, yj, kj = ball[j] return abs(ki-kj) def judge1(i, j, cnt): ok = 0 if cnt == 2 and A <= dist(i, j): ok = 1 if B <= speed(i,j): ok = 1 return ok def judge2(i, j, k): ok = 0 if A <= dist(i,j) + dist(i,k): ok = 1 return ok ans = 1 for bit in range(1 << n): cnt = popcnt(bit) if cnt <= 1: continue for crr in range(n): if not (bit >> crr) & 1: continue for pre1 in range(n): if not (bit >> pre1) & 1: continue ok = judge1(crr, pre1, cnt) if cnt == 2 and ok: dp[bit][crr][pre1] |= dp[bit-(1<> pre2) & 1: continue if judge2(crr, pre1, pre2) or ok: dp[bit][crr][pre1] |= dp[bit - (1<