Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well.

Chef decided to buy a new tablet. His budget is $B$, so he cannot buy a tablet whose price is greater than $B$. Other than that, he only has one criterion — the area of the tablet's screen should be as large as possible. Of course, the screen of a tablet is always a rectangle.

Chef has visited some tablet shops and listed all of his options. In total, there are $N$ available tablets, numbered $1$ through $N$. For each valid $i$, the $i$-th tablet has width $W_{i}$, height $H_{i}$ and price $P_{i}$.

Help Chef choose a tablet which he should buy and find the area of such a tablet's screen, or determine that he cannot buy any tablet.

------  Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first line of each test case contains two space-separated integers $N$ and $B$.
$N$ lines follow. For each $i$ ($1 ≤ i ≤ N$), the $i$-th of these lines contains three space-separated integers $W_{i}$, $H_{i}$ and $P_{i}$.

------  Output ------
For each test case, print a single line. If Chef cannot buy any tablet, it should contain the string "no tablet" (without quotes). Otherwise, it should contain a single integer — the maximum area of the screen of a tablet Chef can buy.

------  Constraints  ------
$1 ≤ T ≤ 100$
$1 ≤ N ≤ 100$
$1 ≤ B ≤ 1,000,000$
$1 ≤ P_{i} ≤ 1,000,000$ for each valid $i$
$1 ≤ W_{i}, H_{i} ≤ 10,000$ for each valid $i$

----- Sample Input 1 ------ 
3
3 6
3 4 4
5 5 7
5 2 5
2 6
3 6 8
5 4 9
1 10
5 5 10
----- Sample Output 1 ------ 
12
no tablet
25
----- explanation 1 ------ 
Example case 1: The first tablet (with screen area $3 \cdot 4 = 12$) is the best option for Chef, since Chef cannot afford the second one and the third one has a smaller screen.

Example case 2: Chef's budget is $6$, but all tablets have higher prices, so Chef cannot buy any tablet.

Example case 3: The price of the only tablet is exactly equal to Chef's budget, so he is able to buy it.

Difficulty: EASY
Tags: Implementation

Complete search
Skill types: Complete search

Starter code:

Solutions:
for _ in range(int(input())):
	(n, b) = map(int, input().split())
	a = []
	m = 0
	for i in range(n):
		x = list(map(int, input().split()))
		a.append(x)
	for i in range(0, n):
		if a[i][2] <= b:
			if a[i][0] * a[i][1] > m:
				m = a[i][0] * a[i][1]
	if m > 0:
		print(m)
	else:
		print('no tablet')


T = int(input())
for i in range(T):
	(N, B) = map(int, input().split())
	m = 0
	for j in range(N):
		(W, H, P) = map(int, input().split())
		if P <= B:
			m = max(W * H, m)
	if m == 0:
		print('no tablet')
	else:
		print(m)


for _ in range(int(input())):
	a = list(map(int, input().split()))
	c = []
	for i in range(a[0]):
		d = list(map(int, input().split()))
		if d[-1] > a[1]:
			continue
		else:
			c.append(d[0] * d[1])
	print(max(c)) if len(c) > 0 else print('no tablet')


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	l = []
	for i in range(a):
		(x, y, z) = map(int, input().split())
		if z <= b:
			l.append(x * y)
	if len(l) == 0:
		print('no tablet')
	else:
		print(max(l))


t = int(input())
for j in range(t):
	(n, b) = map(int, input().split())
	a = 0
	for i in range(n):
		(w, h, p) = map(int, input().split())
		if p <= b and w * h > a:
			a = w * h
	if a == 0:
		print('no tablet')
	else:
		print(a)


n = int(input())
for _ in range(n):
	(N, H) = [int(a) for a in input().split()]
	(k, m) = (0, 0)
	for i in range(N):
		(x, y, z) = [int(a) for a in input().split()]
		if z <= H:
			k = x * y
			if m > k:
				k = m
				m = k
			else:
				m = x * y
	if m != 0:
		print(m)
	else:
		print('no tablet')


for _ in range(0, int(input())):
	a = [int(x) for x in input().split()]
	max1 = 0
	for i in range(0, a[0]):
		b = [int(x) for x in input().split()]
		if b[2] <= a[1]:
			p = b[0] * b[1]
			if p > max1:
				max1 = p
	if max1 == 0:
		print('no tablet')
	else:
		print(max1)


n = int(input())
for i in range(1, n + 1):
	(a, b) = map(int, input().split())
	l = []
	for i in range(1, a + 1):
		(c, d, e) = map(int, input().split())
		if e <= b:
			f = c * d
			l.append(f)
	if len(l) != 0:
		print(max(l))
	else:
		print('no tablet')


for i in range(int(input())):
	(n, b) = map(int, input().split())
	l = []
	for i in range(n):
		(w, h, p) = map(int, input().split())
		if p <= b:
			l.append(w * h)
	if len(l) == 0:
		print('no tablet')
	else:
		print(max(l))


t = int(input())
for i in range(t):
	(n, b) = map(int, input().split())
	x = 0
	for i in range(n):
		(w, h, p) = map(int, input().split())
		if p <= b:
			if w * h > x:
				x = w * h
	if x == 0:
		print('no tablet')
	else:
		print(x)


for _ in range(int(input())):
	(n, b) = map(int, input().split())
	c = []
	for i in range(n):
		(b1, b2, b3) = map(int, input().split())
		if b3 <= b:
			c.append(b1 * b2)
	if len(c) == 0:
		print('no tablet')
	else:
		print(max(c))


T = int(input())
for tc in range(T):
	(n, b) = map(int, input().split(' '))
	sel = []
	for i in range(n):
		(w, h, p) = map(int, input().split(' '))
		if p <= b:
			sel.append(w * h)
	if len(sel) == 0:
		print('no tablet')
	else:
		print(max(sel))


t = int(input())
for i in range(t):
	(n, d) = map(int, input().split())
	lst = []
	for i in range(n):
		(a, b, c) = map(int, input().split())
		if d >= c:
			area = a * b
			lst.append(area)
	if len(lst) == 0:
		print('no tablet')
	else:
		print(max(lst))


for _ in range(int(input())):
	(a, r, d) = ([], [], [])
	mxa = 0
	(n, b) = map(int, input().split())
	for i in range(n):
		l = [int(i) for i in input().split()]
		if l[2] <= b:
			a.append(l)
	for i in a:
		if mxa < i[0] * i[1]:
			mxa = i[0] * i[1]
	if mxa == 0:
		print('no tablet')
	else:
		print(mxa)


tests = int(input())
for i in range(tests):
	str1 = map(int, input().split())
	(N, B) = list(str1)
	list_WHP = []
	for i in range(N):
		str2 = map(int, input().split())
		(W, H, P) = list(str2)
		list_WHP.append([W, H, P])
	area = []
	for i in range(N):
		if list_WHP[i][2] <= B:
			area.append(list_WHP[i][0] * list_WHP[i][1])
	if len(area) == 0:
		print('no tablet')
	else:
		print(max(area))


for _ in range(int(input())):
	(n, b) = map(int, input().split())
	li = []
	screen = 0
	for i in range(n):
		li_data = [int(i) for i in input().split(' ')]
		li.append(li_data)
	for i in range(n):
		if li[i][2] <= b and screen < li[i][0] * li[i][1]:
			screen = li[i][0] * li[i][1]
	print(screen) if screen != 0 else print('no tablet')


t = int(input())
for i in range(t):
	(n, b) = map(int, input().split())
	y = []
	for j in range(n):
		(w, h, p) = map(int, input().split())
		while p <= b:
			x = w * h
			y.append(x)
			break
	if len(y) == 0:
		print('no tablet')
	else:
		print(max(y))


def tab(n, b):
	l = []
	c = 0
	for i in range(n):
		(w, h, p) = map(int, input().split())
		if p <= b:
			c += 1
			d = w * h
			l.append(d)
	if c > 0:
		return max(l)
	else:
		return 'no tablet'
t = int(input())
for i in range(t):
	(n, b) = map(int, input().split())
	print(tab(n, b))


for i in range(int(input())):
	(N, B) = map(int, input().split())
	a = []
	for j in range(N):
		(W, H, P) = map(int, input().split())
		if B >= P:
			a.append(W * H)
	if len(a) > 0:
		print(max(a))
	else:
		print('no tablet')


for t in range(int(input())):
	(N, B) = map(int, input().split())
	size = []
	for i in range(N):
		(w, h, p) = map(int, input().split())
		if p <= B:
			size.append(w * h)
	if len(size) == 0:
		print('no tablet')
	else:
		print(max(size))


t = int(input())
while t > 0:
	(a, b) = input().split(' ')
	a = int(a)
	b = int(b)
	area = []
	for i in range(0, a):
		(c, d, e) = input().split(' ')
		c = int(c)
		d = int(d)
		e = int(e)
		if b >= e:
			area.append(c * d)
	if len(area) != 0:
		max_area = 0
		for i in area:
			if max_area < i:
				max_area = i
		print(max_area)
		t -= 1
	else:
		print('no tablet')
		t -= 1


t = int(input())
for _ in range(t):
	(n, b) = map(int, input().split())
	max_area = -1
	for i in range(n):
		(w, h, p) = map(int, input().split())
		if p <= b:
			area = w * h
			if area > max_area:
				max_area = area
	if max_area == -1:
		print('no tablet')
	else:
		print(max_area)


t = int(input())
for _ in range(t):
	(n, B) = map(int, input().split())
	max = 0
	for i in range(n):
		(b, h, p) = map(int, input().split())
		if B >= p:
			if b * h > max:
				max = b * h
	if max > 0:
		print(max)
	else:
		print('no tablet')


t = int(input())
for i in range(t):
	(n, b) = map(int, input().split())
	maxArea = 0
	for i in range(n):
		(w, h, p) = map(int, input().split())
		area = w * h
		if maxArea < area and b >= p:
			maxArea = area
	if maxArea > 0:
		print(maxArea)
	else:
		print('no tablet')


for _ in range(int(input())):
	(T, B) = map(int, input().split())
	(w, h, p) = (0, 0, 0)
	flag = False
	for i in range(T):
		(wa, ha, pa) = map(int, input().split())
		if pa > B:
			continue
		else:
			flag = True
			if w * h < wa * ha:
				(w, h) = (wa, ha)
	if flag:
		print(w * h)
	else:
		print('no tablet ')


T = int(input())
while T > 0:
	(N, B) = [int(x) for x in input().split()]
	L = []
	for i in range(N):
		temp_l = [int(y) for y in input().split()]
		L.append(temp_l)
	l = []
	for j in range(N):
		if L[j][2] <= B:
			l.append(L[j][0] * L[j][1])
	if l == []:
		print('no tablet')
	else:
		print(max(l))
	T = T - 1


for _ in range(int(input())):
	input_1 = list(map(int, input().split(' ')))
	size = 0
	for i in range(input_1[0]):
		input_2 = list(map(int, input().split(' ')))
		if input_1[1] >= input_2[2] and size < input_2[0] * input_2[1]:
			size = input_2[0] * input_2[1]
	if size:
		print(size)
	else:
		print('no tablet')


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	m = 0
	for i in range(x):
		(w, h, p) = map(int, input().split())
		if y >= p:
			m = max(m, w * h)
	if m == 0:
		print('no tablet')
	else:
		print(m)


cases = int(input())
for x in range(cases):
	(N, B) = map(int, input().split())
	maxm = 0
	for i in range(N):
		(w, h, p) = map(int, input().split())
		if p <= B and maxm < w * h:
			maxm = w * h
	if maxm:
		print(maxm)
	else:
		print('no tablet')


n = int(input())
for i in range(n):
	(a, budget) = map(int, input().split())
	list1 = []
	for j in range(a):
		(w, h, cost) = map(int, input().split())
		if cost <= budget:
			list1.append(w * h)
	if len(list1) == 0:
		print('no tablet')
	else:
		print(max(list1))


cases = int(input())
for x in range(cases):
	(N, B) = map(int, input().split())
	arr = []
	for i in range(N):
		(w, h, p) = map(int, input().split())
		if p <= B:
			arr.append(w * h)
	if arr:
		print(max(arr))
	else:
		print('no tablet')


for i in range(int(input())):
	(n, x) = map(int, input().split())
	l = []
	for i in range(n):
		(a, b, c) = map(int, input().split())
		if c <= x:
			y = a * b
			l.append(y)
	if len(l) == 0:
		print('no tablet')
	else:
		print(max(l))


for _ in range(int(input())):
	(tabs, budget) = map(int, input().split())
	area = 0
	for Avaliable in range(tabs):
		a = list(map(int, input().split()))
		if a[2] <= budget and area <= a[0] * a[1]:
			area = a[0] * a[1]
	if area == 0:
		print('no tablet')
	else:
		print(area)


for _ in range(int(input())):
	(n, b) = map(int, input().split())
	l = []
	for i in range(n):
		l.append(list(map(int, input().split())))
	area = -1
	for i in range(n):
		if l[i][2] <= b:
			if l[i][0] * l[i][1] > area:
				area = l[i][0] * l[i][1]
	if area == -1:
		print('no tablet')
	else:
		print(area)


for i in range(int(input())):
	(N, B) = map(int, input().split())
	a = []
	for j in range(N):
		(w, h, p) = map(int, input().split())
		w1 = w * h
		if p <= B:
			a.append(w1)
	if len(a) == 0:
		print('no tablet')
	else:
		print(max(a))


t = int(input())
for _ in range(t):
	(n, b) = map(int, input().split())
	tab = []
	for i in range(n):
		(w, h, p) = map(int, input().split())
		if p <= b:
			tab.append(w * h)
	if len(tab) == 0:
		print('no tablet')
	else:
		print(max(tab))


for cases in range(int(input())):
	(number, budget) = map(int, input().split())
	dimension = 0
	for tablets in range(number):
		(height, width, price) = map(int, input().split())
		if (price <= budget) & (height * width > dimension):
			dimension = height * width
		else:
			continue
	if dimension == 0:
		print('no tablet')
	else:
		print(dimension)


t = int(input())
while t != 0:
	(a, b) = map(int, input().split(' '))
	lst = []
	for i in range(a):
		(x, y, z) = map(int, input().split(' '))
		if z <= b:
			lst.append(x * y)
	if len(lst) == 0:
		print('no tablet')
	else:
		print(max(lst))
	t -= 1


t = int(input())
for _ in range(t):
	(n, b) = map(int, input().split())
	c = []
	for i in range(n):
		a = list(map(int, input().split()))
		if a[2] <= b:
			c.append(a[0] * a[1])
	if len(c) == 0:
		print('no tablet')
	else:
		print(max(c))


t = int(input())
for i in range(t):
	(n, b) = map(int, input().split())
	s = []
	f = 0
	a = 0
	for i in range(n):
		(l, w, h) = map(int, input().split())
		if h <= b:
			s.append(l * w)
	if len(s) == 0:
		print('no tablet')
	else:
		print(max(s))


import sys
from os import path
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
from collections import defaultdict
for _ in range(int(input())):
	(n, b) = map(int, input().split())
	d = []
	for __ in range(n):
		(w, h, p) = map(int, input().split())
		d.append([w * h, p])
	d = sorted(d, key=lambda x: (x[0], x[1]), reverse=True)
	i = 0
	while d[i][1] > b:
		if i < n - 1:
			i += 1
		else:
			break
	if i < n and d[i][1] <= b:
		print(d[i][0])
	else:
		print('no tablet')


for x in range(int(input())):
	(n, b) = [int(x) for x in input().split()]
	area = 0
	m = 0
	flag = 0
	for i in range(n):
		(w, h, p) = [int(x) for x in input().split()]
		if p <= b:
			area = w * h
			m = max(m, area)
			flag = 1
	if flag == 0:
		print('no tablet')
	else:
		print(m)


for i in range(int(input())):
	(x, y) = map(int, input().split())
	l = []
	for j in range(x):
		(h, w, p) = list(map(int, input().split()))
		a = h * w
		if p <= y:
			l.append(a)
	if len(l) > 0:
		print(max(l))
	else:
		print('no tablet')


T = int(input())
for i in range(0, T):
	(N, B) = map(int, input().split())
	W = []
	H = []
	P = []
	area = []
	search = []
	final = []
	count = 0
	for i in range(0, N):
		(a, b, c) = map(int, input().split())
		W.append(a)
		H.append(b)
		P.append(c)
		x = a * b
		area.append(x)
	for j in range(0, N):
		if P[j] <= B:
			search.append(j)
			count = count + 1
			final.append(area[j])
	if count > 0:
		print(max(final))
	else:
		print('no tablet')


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	x = []
	for i in range(a):
		(w, h, p) = map(int, input().split())
		if p <= b:
			y = w * h
			x.append(y)
	if len(x) > 0:
		print(max(x))
	else:
		print('no tablet')


for i in range(int(input())):
	(n, b) = map(int, input().split())
	m = []
	d = []
	for g in range(n):
		x = [int(x) for x in input().split()]
		m.append(x)
	for f in range(n):
		if m[f][2] <= b:
			e = m[f][0] * m[f][1]
			d.append(e)
	if d:
		print(max(d))
	else:
		print(' no tablet')


n = int(input())
for j in range(n):
	(a, b) = map(int, input().split(' '))
	lis = []
	for i in range(a):
		(c, d, e) = map(int, input().split(' '))
		if e <= b:
			lis.append(c * d)
	if len(lis) == 0:
		print('no tablet')
	else:
		print(max(lis))


t = int(input())
for i in range(t):
	x = []
	y = []
	z = []
	l = []
	m = []
	(n, b) = map(int, input().split())
	for j in range(n):
		(w, h, p) = map(int, input().split())
		x.append(w)
		y.append(h)
		z.append(p)
		if z[j] <= b:
			l.append(z[j])
			m.append(x[j] * y[j])
	if len(m) == 0:
		print('no tablet')
	else:
		print(max(m))


cases = int(input())
for case in range(cases):
	(N_tablet, budget) = map(int, input().split())
	tablet_area = []
	for tablet in range(N_tablet):
		(width, height, price) = map(int, input().split())
		area = width * height
		if price <= budget:
			tablet_area.append(area)
	if len(tablet_area) == 0:
		print('no tablet')
	else:
		maks_of_area = max(tablet_area)
		print(maks_of_area)


t = int(input())
for i in range(t):
	(n, b) = map(int, input().split())
	p = 0
	for j in range(n):
		(c, d, e) = map(int, input().split())
		f = c * d
		if f >= p and e <= b:
			p = f
	if p != 0:
		print(p)
	else:
		print('no tablet')


for i in range(int(input())):
	(n, b) = map(int, input().split())
	li = []
	for i in range(n):
		L = input().split()
		l = [eval(i) for i in L]
		if l[2] <= b:
			li.append(l)
	if len(li) == 0:
		print('no tablet')
	else:
		maxa = 0
		for i in range(len(li)):
			if li[i][0] * li[i][1] > maxa:
				maxa = li[i][0] * li[i][1]
		print(maxa)


t = int(input())
for i in range(t):
	(n, b) = map(int, input().split())
	max1 = 0
	count = 0
	for i in range(n):
		(w, h, p) = map(int, input().split())
		if p <= b:
			n = w * h
			if n >= max1:
				max1 = n
				count = count + 1
	if count == 0:
		print('no tablet')
	else:
		print(max1)


for i in range(int(input())):
	(n, b) = map(int, input().split())
	s = 0
	for i in range(n):
		l = list(map(int, input().split()))
		if l[2] <= b and l[0] * l[1] > s:
			s = l[0] * l[1]
	if s == 0:
		print('no tablet')
	else:
		print(s)


t = int(input())
for i in range(t):
	(n, b) = map(int, input().split())
	a = []
	for i in range(n):
		(w, h, p) = map(int, input().split())
		area = w * h
		cond = p <= b
		if cond == True:
			a.append(area)
	if len(a) == 0:
		print('no tablet')
	else:
		print(max(a))


for i in range(int(input())):
	(a, b) = map(int, input().split())
	p = []
	c = 0
	for j in range(a):
		l = list(map(int, input().split()))
		if l[-1] <= b:
			p.append(l[0] * l[1])
			c += 1
	if c == 0:
		print('no tablet')
	else:
		print(max(p))


a = int(input())
for i in range(a):
	(n, b) = map(int, input().split())
	e = []
	m = 0
	c = 0
	for j in range(n):
		lst = list(map(int, input().split()))
		if lst[-1] > b:
			e.append(0)
		else:
			m = lst[0] * lst[1]
			e.append(m)
	if max(e) == 0:
		print('no tablet')
	else:
		print(max(e))


t = int(input())
for tstcs in range(t):
	(n, b) = map(int, input().split())
	maxArea = 0
	for i in range(n):
		(w, h, p) = map(int, input().split())
		if p <= b:
			if w * h > maxArea:
				maxArea = w * h
		else:
			continue
	if maxArea == 0:
		print('no tablet')
	else:
		print(maxArea)