A rectangle with its opposite corners in $(0, 0)$ and $(w, h)$ and sides parallel to the axes is drawn on a plane.

You are given a list of lattice points such that each point lies on a side of a rectangle but not in its corner. Also, there are at least two points on every side of a rectangle.

Your task is to choose three points in such a way that:

exactly two of them belong to the same side of a rectangle;

the area of a triangle formed by them is maximum possible.

Print the doubled area of this triangle. It can be shown that the doubled area of any triangle formed by lattice points is always an integer.


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 10^4$) — the number of testcases.

The first line of each testcase contains two integers $w$ and $h$ ($3 \le w, h \le 10^6$) — the coordinates of the corner of a rectangle.

The next two lines contain the description of the points on two horizontal sides. First, an integer $k$ ($2 \le k \le 2 \cdot 10^5$) — the number of points. Then, $k$ integers $x_1 < x_2 < \dots < x_k$ ($0 < x_i < w$) — the $x$ coordinates of the points in the ascending order. The $y$ coordinate for the first line is $0$ and for the second line is $h$.

The next two lines contain the description of the points on two vertical sides. First, an integer $k$ ($2 \le k \le 2 \cdot 10^5$) — the number of points. Then, $k$ integers $y_1 < y_2 < \dots < y_k$ ($0 < y_i < h$) — the $y$ coordinates of the points in the ascending order. The $x$ coordinate for the first line is $0$ and for the second line is $w$.

The total number of points on all sides in all testcases doesn't exceed $2 \cdot 10^5$.


-----Output-----

For each testcase print a single integer — the doubled maximum area of a triangle formed by such three points that exactly two of them belong to the same side.


-----Examples-----

Input
3
5 8
2 1 2
3 2 3 4
3 1 4 6
2 4 5
10 7
2 3 9
2 1 7
3 1 3 4
3 4 5 6
11 5
3 1 6 8
3 3 6 8
3 1 3 4
2 2 4
Output
25
42
35


-----Note-----

The points in the first testcase of the example:

$(1, 0)$, $(2, 0)$;

$(2, 8)$, $(3, 8)$, $(4, 8)$;

$(0, 1)$, $(0, 4)$, $(0, 6)$;

$(5, 4)$, $(5, 5)$.

The largest triangle is formed by points $(0, 1)$, $(0, 6)$ and $(5, 4)$ — its area is $\frac{25}{2}$. Thus, the doubled area is $25$. Two points that are on the same side are: $(0, 1)$ and $(0, 6)$.

Difficulty: EASY
Tags: Geometry

Mathematics

Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
t = int(input())
res = []
for j in range(t):
	a = list(map(int, input().split()))
	w = a[0]
	h = a[1]
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	e = list(map(int, input().split()))
	bb = (b[-1] - b[1]) * h
	cc = (c[-1] - c[1]) * h
	dd = (d[-1] - d[1]) * w
	ee = (e[-1] - e[1]) * w
	r = max(bb, cc, dd, ee)
	res.append(r)
for i in range(len(res)):
	print(res[i])


from collections import Counter
from math import ceil, floor, log, gcd
import bisect as bs
import sys
input = sys.stdin.readline
inp_lis = lambda : list(map(int, input().split()))
inp_multi = lambda : map(int, input().split())
inp_int = lambda : int(input().strip())
for _ in range(int(input().strip())):
	(w, h) = inp_multi()
	l = []
	for q in range(4):
		t = inp_lis()
		li = t[1:]
		li.sort()
		if q < 2:
			h1 = h
		else:
			h1 = w
		l.append((li[-1] - li[0]) * h1)
	print(max(l))


for _ in range(int(input())):
	(w, h) = map(int, input().split())
	ans = 0
	for i in range(4):
		a = [int(x) for x in input().split()][1:]
		ans = max(ans, (a[-1] - a[0]) * (h if i < 2 else w))
	print(ans)


for _ in range(0, int(input())):
	(a, b) = map(int, input().split())
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	e = list(map(int, input().split()))
	f = list(map(int, input().split()))
	ca = c[len(c) - 1] - c[1]
	da = d[len(d) - 1] - d[1]
	ea = e[len(e) - 1] - e[1]
	fa = f[len(f) - 1] - f[1]
	print(max(ea * a, fa * a, da * b, ca * b))


def main():
	T = int(input())
	for i in range(T):
		(h, w) = list(map(int, input().split(' ')))
		x_1 = list(map(int, input().split(' ')))
		x_2 = list(map(int, input().split(' ')))
		y_1 = list(map(int, input().split(' ')))
		y_2 = list(map(int, input().split(' ')))
		x_1_a = (x_1[len(x_1) - 1] - x_1[1]) * w
		x_2_a = (x_2[len(x_2) - 1] - x_2[1]) * w
		y_1_a = (y_1[len(y_1) - 1] - y_1[1]) * h
		y_2_a = (y_2[len(y_2) - 1] - y_2[1]) * h
		res = max(max(max(x_1_a, x_2_a), y_1_a), y_2_a)
		print(res)
main()


from sys import stdin
for _ in range(int(stdin.readline())):
	(w, h) = map(int, stdin.readline().split())
	y0 = list(map(int, stdin.readline().split()))
	yh = list(map(int, stdin.readline().split()))
	x0 = list(map(int, stdin.readline().split()))
	xw = list(map(int, stdin.readline().split()))
	a = (y0[-1] - y0[1]) * h
	b = (yh[-1] - yh[1]) * h
	c = (x0[-1] - x0[1]) * w
	d = (xw[-1] - xw[1]) * w
	print(max(a, b, c, d))


from sys import stdin
input = stdin.readline

def answer():
	base = max(x1[-1] - x1[1], x2[-1] - x2[1])
	ans = base * h
	base = max(y1[-1] - y1[1], y2[-1] - y2[1])
	ans = max(ans, base * w)
	return ans
for T in range(int(input())):
	(w, h) = map(int, input().split())
	x1 = list(map(int, input().split()))
	x2 = list(map(int, input().split()))
	y1 = list(map(int, input().split()))
	y2 = list(map(int, input().split()))
	print(answer())


t = int(input())
res = []
for i in range(t):
	l = input().split()
	w = int(l[0])
	h = int(l[1])
	max = 0
	for i in range(4):
		s = input().split()
		s = [int(j) for j in s]
		if i == 0 or i == 1:
			temp = (s[-1] - s[1]) * h
			if max < temp:
				max = temp
		else:
			temp = (s[-1] - s[1]) * w
			if max < temp:
				max = temp
	res.append(max)
for i in res:
	print(i)


n = int(input())
results = []
for i in range(n):
	(w, h) = input().split()
	(w, h) = (int(w), int(h))
	lower = input().split()
	mlower = int(lower[-1]) - int(lower[1])
	upper = input().split()
	mupper = int(upper[-1]) - int(upper[1])
	left = input().split()
	mleft = int(left[-1]) - int(left[1])
	right = input().split()
	mright = int(right[-1]) - int(right[1])
	results.append(max(h * max(mlower, mupper), w * max(mleft, mright)))
for result in results:
	print(result)


t = int(input())
while t:
	(w, h) = map(int, input().split())
	h1 = []
	h2 = []
	v1 = []
	v2 = []
	info1 = list(map(int, input().split()))
	info2 = list(map(int, input().split()))
	h1 = info1[1:]
	h2 = info2[1:]
	h1.sort()
	h2.sort()
	info1 = list(map(int, input().split()))
	info2 = list(map(int, input().split()))
	v1 = info1[1:]
	v2 = info2[1:]
	v1.sort()
	v2.sort()
	ans = max((h1[-1] - h1[0]) * h, (h2[-1] - h2[0]) * h, (v1[-1] - v1[0]) * w, (v2[-1] - v2[0]) * w)
	print(ans)
	t -= 1


def find(w, h, hdown, hup, vleft, vright):
	x = max(int(hdown[-1]) - int(hdown[1]), int(hup[-1]) - int(hup[1]))
	y = max(int(vleft[-1]) - int(vleft[1]), int(vright[-1]) - int(vright[1]))
	return max(x * h, y * w)
cases = int(input())
for _ in range(cases):
	line = input().split()
	(w, h) = (int(line[0]), int(line[1]))
	hdown = input().split()
	hup = input().split()
	vleft = input().split()
	vright = input().split()
	print(find(w, h, hdown, hup, vleft, vright))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	print(max((a[-1] - a[1]) * m, (b[-1] - b[1]) * m, (c[-1] - c[1]) * n, (d[-1] - d[1]) * n))


def squer(x1, y1, x2, y2, x3, y3):
	A = abs(x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2))
	return A
t = int(input())
for i in range(t):
	(w, h) = [int(o) for o in input().split()]
	xd = [int(o) for o in input().split()[1:]]
	xu = [int(o) for o in input().split()[1:]]
	yl = [int(o) for o in input().split()[1:]]
	yr = [int(o) for o in input().split()[1:]]
	maxx = 0
	for x in xu:
		maxx = max(maxx, squer(xd[0], 0, xd[-1], 0, x, h))
	for y in yl:
		maxx = max(maxx, squer(xd[0], 0, xd[-1], 0, 0, y))
	for y in yr:
		maxx = max(maxx, squer(xd[0], 0, xd[-1], 0, w, y))
	for x in xd:
		maxx = max(maxx, squer(xu[0], h, xu[-1], h, x, 0))
	for y in yl:
		maxx = max(maxx, squer(xu[0], h, xu[-1], h, 0, y))
	for y in yr:
		maxx = max(maxx, squer(xu[0], h, xu[-1], h, w, y))
	for x in xu:
		maxx = max(maxx, squer(0, yl[0], 0, yl[-1], x, h))
	for x in xd:
		maxx = max(maxx, squer(0, yl[0], 0, yl[-1], x, 0))
	for y in yr:
		maxx = max(maxx, squer(0, yl[0], 0, yl[-1], w, y))
	for x in xu:
		maxx = max(maxx, squer(w, yr[0], w, yr[-1], x, h))
	for y in yl:
		maxx = max(maxx, squer(w, yr[0], w, yr[-1], 0, y))
	for x in xd:
		maxx = max(maxx, squer(w, yr[0], w, yr[-1], x, 0))
	print(maxx)


T = int(input())
for i in range(T):
	[w, h] = list(map(int, input().split()))
	a = list(map(int, input().split()))
	max = (a[-1] - a[1]) * h
	a = list(map(int, input().split()))
	temp = (a[-1] - a[1]) * h
	if temp > max:
		max = temp
	a = list(map(int, input().split()))
	temp = (a[-1] - a[1]) * w
	if temp > max:
		max = temp
	a = list(map(int, input().split()))
	temp = (a[-1] - a[1]) * w
	if temp > max:
		max = temp
	print(max)


from sys import stdin
import math

def main():
	t = int(stdin.readline())
	for i in range(t):
		x = stdin.readline().split()
		w = int(x[0])
		h = int(x[1])
		w_1 = stdin.readline().split()[1:]
		w_2 = stdin.readline().split()[1:]
		h_1 = stdin.readline().split()[1:]
		h_2 = stdin.readline().split()[1:]
		for u in range(len(w_1)):
			w_1[u] = int(w_1[u])
		for u in range(len(w_2)):
			w_2[u] = int(w_2[u])
		for u in range(len(h_1)):
			h_1[u] = int(h_1[u])
		for u in range(len(h_2)):
			h_2[u] = int(h_2[u])
		w_1.sort()
		w_2.sort()
		h_1.sort()
		h_2.sort()
		a = (w_1[-1] - w_1[0]) * h
		b = max((w_2[-1] - w_2[0]) * h, a)
		c = (h_1[-1] - h_1[0]) * w
		d = max((h_2[-1] - h_2[0]) * w, c)
		print(max(b, d))
	return
main()


t = int(input())
for k in range(t):
	(x, y) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l3 = list(map(int, input().split()))
	l4 = list(map(int, input().split()))
	m1 = (l1[-1] - l1[1]) * y
	m2 = (l2[-1] - l2[1]) * y
	m3 = (l3[-1] - l3[1]) * x
	m4 = (l4[-1] - l4[1]) * x
	res = max([m1, m2, m3, m4])
	print(res)


t = int(input())
for i in range(t):
	res = []
	(w, h) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()][1:]
	b = [int(x) for x in input().split()][1:]
	c = [int(x) for x in input().split()][1:]
	d = [int(x) for x in input().split()][1:]
	res.append(h * (a[-1] - a[0]))
	res.append(h * (b[-1] - b[0]))
	res.append(w * (c[-1] - c[0]))
	res.append(w * (d[-1] - d[0]))
	print(max(res))


def solve():
	(w, h) = map(int, input().split())
	h1 = list(map(int, input().split()))
	h2 = list(map(int, input().split()))
	v1 = list(map(int, input().split()))
	v2 = list(map(int, input().split()))
	maxh1 = (h1[h1[0]] - h1[1]) * h
	maxh2 = (h2[h2[0]] - h2[1]) * h
	maxv1 = (v1[v1[0]] - v1[1]) * w
	maxv2 = (v2[v2[0]] - v2[1]) * w
	print(max(maxh1, maxh2, maxv1, maxv2))
cases = int(input())
for i in range(cases):
	solve()


t = int(input())
while t:
	t -= 1
	(w, h) = map(int, input().split())
	h1 = list(map(int, input().split()))
	h2 = list(map(int, input().split()))
	v1 = list(map(int, input().split()))
	v2 = list(map(int, input().split()))
	mh = h * max(h1[-1] - h1[1], h2[-1] - h2[1])
	mv = w * max(v1[-1] - v1[1], v2[-1] - v2[1])
	print(max(mh, mv))


import sys

def main():
	input = sys.stdin.readline
	print = sys.stdout.write
	t = int(input())
	for j in [0] * t:
		(w, h) = map(int, input().split())
		nums1 = list(map(int, input().split()))
		nums2 = list(map(int, input().split()))
		nums3 = list(map(int, input().split()))
		nums4 = list(map(int, input().split()))
		sidex = max(nums1[-1] - nums1[1], nums2[-1] - nums2[1])
		sidey = max(nums3[-1] - nums3[1], nums4[-1] - nums4[1])
		print(str(max(sidex * h, sidey * w)) + '\n')
main()


t = int(input())
for i in range(t):
	(w, h) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	x = max(a[-1] - a[1], b[-1] - b[1]) * h
	y = max(c[-1] - c[1], d[-1] - d[1]) * w
	print(max(x, y))


n = int(input())
for i in range(n):
	(w, h) = map(int, input().split())
	h1 = input().split()
	h2 = input().split()
	v1 = input().split()
	v2 = input().split()
	print(max(h * max(int(h1[-1]) - int(h1[1]), int(h2[-1]) - int(h2[1])), w * max(int(v1[-1]) - int(v1[1]), int(v2[-1]) - int(v2[1]))))


test = int(input())
for i in range(test):
	(w, h) = map(int, input().split())
	x1 = list(map(int, input().split()))
	xo = x1[len(x1) - 1] - x1[1]
	x2 = list(map(int, input().split()))
	x = x2[len(x2) - 1] - x2[1]
	y1 = list(map(int, input().split()))
	yo = y1[len(y1) - 1] - y1[1]
	y2 = list(map(int, input().split()))
	y = y2[len(y2) - 1] - y2[1]
	print(max(xo * h, x * h, yo * w, y * w))


import sys
import bisect
import math
from collections import deque
input = lambda : sys.stdin.readline().strip()
mod = 10 ** 9 + 7

def solve():
	(w, h) = map(int, input().split())
	x1 = list(map(int, input().split()))
	x2 = list(map(int, input().split()))
	y1 = list(map(int, input().split()))
	y2 = list(map(int, input().split()))
	return max((x1[-1] - x1[1]) * h, (x2[-1] - x2[1]) * h, (y1[-1] - y1[1]) * w, (y2[-1] - y2[1]) * w)
t = 1
t = int(input())
for _ in range(t):
	print(solve())


import sys
from sys import stdin, stdout
from math import ceil, floor, sqrt, log, log2, log10
from collections import Counter
int_max = float('inf')
int_min = -float('inf')
mod = 10 ** 9 + 7
ANS = []
input = stdin.readline

def solve():
	pass
t = int(input())
for i in range(t):
	(w, h) = map(int, input().split())
	a1 = list(map(int, input().split()))
	a2 = list(map(int, input().split()))
	b1 = list(map(int, input().split()))
	b2 = list(map(int, input().split()))
	maxx = -1
	maxx = max(maxx, h * (a1[-1] - a1[1]), h * (a2[-1] - a2[1]))
	maxx = max(maxx, w * (b1[-1] - b1[1]), w * (b2[-1] - b2[1]))
	print(maxx)


n = int(input())
for i in range(n):
	L = input().split(' ')
	w = int(L[0])
	h = int(L[1])
	L = input().split(' ')
	s1 = (int(L[-1]) - int(L[1])) * h
	L = input().split(' ')
	s2 = (int(L[-1]) - int(L[1])) * h
	L = input().split(' ')
	s3 = (int(L[-1]) - int(L[1])) * w
	L = input().split(' ')
	s4 = (int(L[-1]) - int(L[1])) * w
	print(max(s1, s2, s3, s4))


def solve():
	(w, h) = list(map(int, input().split()))
	x_l = list(map(int, input().split()))[1:]
	best = h * (x_l[-1] - x_l[0])
	x_h = list(map(int, input().split()))[1:]
	best = max(best, h * (x_h[-1] - x_h[0]))
	y_l = list(map(int, input().split()))[1:]
	best = max(best, w * (y_l[-1] - y_l[0]))
	y_r = list(map(int, input().split()))[1:]
	best = max(best, w * (y_r[-1] - y_r[0]))
	print(best)
for _ in range(int(input())):
	solve()


import sys

def solve():
	T = int(sys.stdin.readline().rstrip())
	for _ in range(T):
		(w, h) = list(map(int, sys.stdin.readline().rstrip().split(' ')))
		widths = []
		(_, *X) = list(map(int, sys.stdin.readline().rstrip().split(' ')))
		widths.append(X[len(X) - 1] - X[0])
		(_, *X) = list(map(int, sys.stdin.readline().rstrip().split(' ')))
		widths.append(X[len(X) - 1] - X[0])
		heights = []
		(_, *Y) = list(map(int, sys.stdin.readline().rstrip().split(' ')))
		heights.append(Y[len(Y) - 1] - Y[0])
		(_, *Y) = list(map(int, sys.stdin.readline().rstrip().split(' ')))
		heights.append(Y[len(Y) - 1] - Y[0])
		print(max(widths[0] * h, widths[1] * h, heights[0] * w, heights[1] * w))
solve()


t = int(input())
for _ in range(t):
	(w, h) = map(int, input().split())
	top = list(map(int, input().split()))
	bottom = list(map(int, input().split()))
	left = list(map(int, input().split()))
	right = list(map(int, input().split()))
	ans = max((top[-1] - top[1]) * h, (bottom[-1] - bottom[1]) * h, (left[-1] - left[1]) * w, (right[-1] - right[1]) * w)
	print(ans)


def solve():
	(w, h) = map(int, input().split())
	s1 = list(map(int, input().split()))[1:]
	s2 = list(map(int, input().split()))[1:]
	s3 = list(map(int, input().split()))[1:]
	s4 = list(map(int, input().split()))[1:]
	print(max((max(s1) - min(s1)) * h, (max(s2) - min(s2)) * h, (max(s3) - min(s3)) * w, (max(s4) - min(s4)) * w))
t = int(input())
for _ in range(t):
	solve()


a = int(input())
for x in range(a):
	(b, c) = map(int, input().split())
	e = list(map(int, input().split()))
	f = list(map(int, input().split()))
	g = list(map(int, input().split()))
	h = list(map(int, input().split()))
	j = max(c * (e[-1] - e[1]), c * (f[-1] - f[1]), b * (g[-1] - g[1]), b * (h[-1] - h[1]))
	print(j)


import sys
import pprint
import logging
from logging import getLogger

def input():
	return sys.stdin.readline().rstrip('\r\n')
logging.basicConfig(format='%(message)s', level=logging.WARNING)
logger = getLogger(__name__)
logger.setLevel(logging.INFO)

def debug(msg, *args):
	logger.info(f'{msg}={pprint.pformat(args)}')

def slv():
	(w, h) = map(int, input().split())
	ans = 0
	for i in range(4):
		a = list(map(int, input().split()))[1:]
		ans = max(ans, (a[-1] - a[0]) * (h if i < 2 else w))
	print(ans)
for _ in range(int(input())):
	slv()


import os
import sys
from io import BytesIO, IOBase
import math
from collections import Counter, deque
import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
MOD = 10 ** 9 + 7

def solve():
	(a, b) = map(int, input().split())
	ans = 0
	for i in range(4):
		l = list(map(int, input().split()))
		l = l[1:]
		if i < 2:
			ans = max(ans, (l[-1] - l[0]) * b)
		else:
			ans = max(ans, (l[-1] - l[0]) * a)
	print(ans)
for _ in range(int(input())):
	solve()


t = int(input())
for i in range(t):
	s1 = input().split()
	s2 = input().split()
	s3 = input().split()
	s4 = input().split()
	s5 = input().split()
	w = int(s1[0])
	h = int(s1[1])
	xmax1 = int(s2[-1])
	xmin1 = int(s2[1])
	xmax2 = int(s3[-1])
	xmin2 = int(s3[1])
	ymax1 = int(s4[-1])
	ymin1 = int(s4[1])
	ymax2 = int(s5[-1])
	ymin2 = int(s5[1])
	x = max(xmax1 - xmin1, xmax2 - xmin2)
	y = max(ymax1 - ymin1, ymax2 - ymin2)
	ans = max(x * h, y * w)
	print(ans)


t = int(input())
for q in range(t):
	(w, h) = map(int, input().split())
	m1 = []
	m2 = []
	m1 = list(map(int, input().split()))
	m2 = list(map(int, input().split()))
	k1 = m1[0]
	k2 = m2[0]
	max1 = max(m1[k1] - m1[1], m2[k2] - m2[1])
	m1 = []
	m2 = []
	m1 = list(map(int, input().split()))
	m2 = list(map(int, input().split()))
	k1 = m1[0]
	k2 = m2[0]
	max2 = max(m1[k1] - m1[1], m2[k2] - m2[1])
	print(max(w * max2, h * max1))


t = int(input())
for i in range(t):
	(w, h) = tuple(map(int, input().split()))
	l0h = list(map(int, input().split()))[1:]
	lhh = list(map(int, input().split()))[1:]
	l0v = list(map(int, input().split()))[1:]
	lwv = list(map(int, input().split()))[1:]
	(areax, areay) = (max(l0h[-1] - l0h[0], lhh[-1] - lhh[0]) * h, max(l0v[-1] - l0v[0], lwv[-1] - lwv[0]) * w)
	print(max(areax, areay))


for k in range(int(input())):
	(w, h) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	ans1 = (a[-1] - a[1]) * h
	ans2 = (b[-1] - b[1]) * h
	ans3 = (c[-1] - c[1]) * w
	ans4 = (d[-1] - d[1]) * w
	ans = max(ans1, ans2, ans3, ans4)
	print(ans)


t = int(input())
for _ in range(t):
	(h, w) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l3 = list(map(int, input().split()))
	l4 = list(map(int, input().split()))
	x1 = l1[-1] - l1[1]
	x2 = l2[-1] - l2[1]
	x3 = l3[-1] - l3[1]
	x4 = l4[-1] - l4[1]
	area1 = x1 * w
	area2 = x2 * w
	area3 = x3 * h
	area4 = x4 * h
	print(max(area1, area2, area3, area4))


import sys
from collections import deque
import math
from bisect import bisect_left
from functools import cmp_to_key

def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return sys.stdin.readline().strip()

def FACT(n, mod):
	s = 1
	facts = [1]
	for i in range(1, n + 1):
		s *= i
		s %= mod
		facts.append(s)
	return facts[n]

def C(n, k, mod):
	return FACT(n, mod) * pow(FACT(k, mod) * FACT(n - k, mod) % mod, mod - 2, mod) % mod

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def dis(a, b):
	(x, y) = a
	(x1, y1) = b
	return ((x - x1) ** 2 + (y - y1) ** 2) ** 0.5

def area(a, b, c):
	x = dis(a, b)
	y = dis(b, c)
	z = dis(a, c)
	p = (x + y + z) / 2
	s = (4 * p * (p - x) * (p - y) * (p - z)) ** 0.5
	return s
for _ in range(II()):
	(w, h) = MI()
	l = LI()
	d1 = l.pop(0)
	l1 = LI()
	d2 = l1.pop(0)
	l2 = LI()
	d3 = l2.pop(0)
	l3 = LI()
	d4 = l3.pop(0)
	temp = [(max(l), 0), (min(l), 0), (max(l1), h), (min(l1), h), (0, max(l2)), (0, min(l2)), (w, max(l3)), (w, min(l3))]
	m = 0
	for i in temp:
		if i[1] != 0:
			m = max(m, area(temp[0], temp[1], i))
	for i in temp:
		if i[0] != 0:
			m = max(m, area(temp[-3], temp[-4], i))
	for i in temp:
		if i[1] != h:
			m = max(m, area(temp[2], temp[3], i))
	for i in temp:
		if i[0] != w:
			m = max(m, area(temp[-1], temp[-2], i))
	print(round(m))


import sys, array, bisect, collections, heapq, itertools, math, functools
sys.setrecursionlimit(100000)

def _r():
	return sys.stdin.buffer.readline()

def rs():
	return _r().decode('ascii').strip()

def rn():
	return int(_r())

def rnt():
	return tuple(map(int, _r().split()))

def rnl():
	return list(rnt())

def rna():
	return array.array('q', rnt())

def pnl(l):
	print(' '.join(map(str, l)))
for _ in range(rn()):
	(w, h) = rnt()
	x1 = rnl()[1:]
	x2 = rnl()[1:]
	y1 = rnl()[1:]
	y2 = rnl()[1:]
	p1 = (x1[-1] - x1[0]) * h
	p2 = (x2[-1] - x2[0]) * h
	p3 = (y1[-1] - y1[0]) * w
	p4 = (y2[-1] - y2[0]) * w
	print(max(p1, p2, p3, p4))


import heapq
from collections import Counter
import math
import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def inis():
	return input().split()
for _ in range(inp()):
	(w, h) = invr()
	mx = 0
	for i in range(4):
		x = inlt()
		x = x[1:]
		mx = max(mx, (x[-1] - x[0]) * (h if i < 2 else w))
	print(mx)


import sys
tokens = ''.join(sys.stdin.readlines()).split()[::-1]

def next():
	return tokens.pop()

def nextInt():
	return int(next())

def nextFloat():
	return float(next())

def getIntArray(n):
	return [nextInt() for _ in range(n)]

def getFloatArray(n):
	return [nextFloat() for _ in range(n)]

def getStringArray(n):
	return [next() for _ in range(n)]
testcase = True

def solve(testcase=1):
	(W, H) = (nextInt(), nextInt())
	hori = [getIntArray(nextInt()), getIntArray(nextInt())]
	vert = [getIntArray(nextInt()), getIntArray(nextInt())]
	ans = 0
	ans = max(ans, H * max(hori[0][-1] - hori[0][0], hori[1][-1] - hori[1][0]))
	ans = max(ans, W * max(vert[0][-1] - vert[0][0], vert[1][-1] - vert[1][0]))
	print(ans)
	pass
if testcase is None:
	testcaseCount = 1
	while tokens:
		solve(testcaseCount)
		testcaseCount += 1
else:
	testcaseCount = nextInt() if testcase else 1
	for tc in range(testcaseCount):
		solve(tc + 1)
	assert not tokens


N = int(input())
for i in range(N):
	(w, h) = map(int, input().split())
	max_area = 0
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l3 = list(map(int, input().split()))
	l4 = list(map(int, input().split()))
	max_area = max(max_area, (l1[-1] - l1[1]) * h)
	max_area = max(max_area, (l2[-1] - l2[1]) * h)
	max_area = max(max_area, (l3[-1] - l3[1]) * w)
	max_area = max(max_area, (l4[-1] - l4[1]) * w)
	print(max_area)


def find_points(l: list):
	if len(l) >= 2:
		(min_point, max_point) = (l[0], l[-1])
		return (True, min_point, max_point)
	else:
		max_point = l[-1]
		return (False, 0, max_point)
tests = int(input())
for test in range(tests):
	(w, h) = map(int, input().split())
	up = list(map(int, input().split()))[1:]
	down = list(map(int, input().split()))[1:]
	right = list(map(int, input().split()))[1:]
	left = list(map(int, input().split()))[1:]
	up = find_points(up)
	down = find_points(down)
	right = find_points(right)
	left = find_points(left)
	ans_1 = (up[2] - up[1]) * h
	ans_2 = (down[2] - down[1]) * h
	ans_3 = (right[2] - right[1]) * w
	ans_4 = (left[2] - left[1]) * w
	print(max(ans_1, ans_2, ans_3, ans_4))


for _ in range(int(input())):
	(w, h) = map(int, input().split())
	points = [list(map(int, input().split()))[1:] for _ in range(4)]
	ans = 0
	a = max(max(points[0]) - min(points[0]), max(points[1]) - min(points[1]))
	b = max(max(points[2]) - min(points[2]), max(points[3]) - min(points[3]))
	print(max(a * h, b * w))


t = int(input())
for caseNr in range(1, t + 1):
	(w, h) = list(map(int, input().split()))
	x0s = list(map(int, input().split()))
	xhs = list(map(int, input().split()))
	_0ys = list(map(int, input().split()))
	wys = list(map(int, input().split()))
	x0s = [[f, 0] for f in x0s[1:]]
	xhs = [[f, h] for f in xhs[1:]]
	_0ys = [[0, f] for f in _0ys[1:]]
	wys = [[w, f] for f in wys[1:]]
	cur_max = 0
	firstA = x0s[0]
	firstB = x0s[-1]
	for eleC in xhs:
		cur_area = abs(firstA[0] * (firstB[1] - eleC[1]) + firstB[0] * (eleC[1] - firstA[1]) + eleC[0] * (firstA[1] - firstB[1]))
		cur_max = max(cur_max, cur_area)
	for eleC in _0ys:
		cur_area = abs(firstA[0] * (firstB[1] - eleC[1]) + firstB[0] * (eleC[1] - firstA[1]) + eleC[0] * (firstA[1] - firstB[1]))
		cur_max = max(cur_max, cur_area)
	for eleC in wys:
		cur_area = abs(firstA[0] * (firstB[1] - eleC[1]) + firstB[0] * (eleC[1] - firstA[1]) + eleC[0] * (firstA[1] - firstB[1]))
		cur_max = max(cur_max, cur_area)
	firstA = xhs[0]
	firstB = xhs[-1]
	for eleC in x0s:
		cur_area = abs(firstA[0] * (firstB[1] - eleC[1]) + firstB[0] * (eleC[1] - firstA[1]) + eleC[0] * (firstA[1] - firstB[1]))
		cur_max = max(cur_max, cur_area)
	for eleC in _0ys:
		cur_area = abs(firstA[0] * (firstB[1] - eleC[1]) + firstB[0] * (eleC[1] - firstA[1]) + eleC[0] * (firstA[1] - firstB[1]))
		cur_max = max(cur_max, cur_area)
	for eleC in wys:
		cur_area = abs(firstA[0] * (firstB[1] - eleC[1]) + firstB[0] * (eleC[1] - firstA[1]) + eleC[0] * (firstA[1] - firstB[1]))
		cur_max = max(cur_max, cur_area)
	firstA = _0ys[0]
	firstB = _0ys[-1]
	for eleC in x0s:
		cur_area = abs(firstA[0] * (firstB[1] - eleC[1]) + firstB[0] * (eleC[1] - firstA[1]) + eleC[0] * (firstA[1] - firstB[1]))
		cur_max = max(cur_max, cur_area)
	for eleC in xhs:
		cur_area = abs(firstA[0] * (firstB[1] - eleC[1]) + firstB[0] * (eleC[1] - firstA[1]) + eleC[0] * (firstA[1] - firstB[1]))
		cur_max = max(cur_max, cur_area)
	for eleC in wys:
		cur_area = abs(firstA[0] * (firstB[1] - eleC[1]) + firstB[0] * (eleC[1] - firstA[1]) + eleC[0] * (firstA[1] - firstB[1]))
		cur_max = max(cur_max, cur_area)
	firstA = wys[0]
	firstB = wys[-1]
	for eleC in x0s:
		cur_area = abs(firstA[0] * (firstB[1] - eleC[1]) + firstB[0] * (eleC[1] - firstA[1]) + eleC[0] * (firstA[1] - firstB[1]))
		cur_max = max(cur_max, cur_area)
	for eleC in xhs:
		cur_area = abs(firstA[0] * (firstB[1] - eleC[1]) + firstB[0] * (eleC[1] - firstA[1]) + eleC[0] * (firstA[1] - firstB[1]))
		cur_max = max(cur_max, cur_area)
	for eleC in _0ys:
		cur_area = abs(firstA[0] * (firstB[1] - eleC[1]) + firstB[0] * (eleC[1] - firstA[1]) + eleC[0] * (firstA[1] - firstB[1]))
		cur_max = max(cur_max, cur_area)
	print(cur_max)


r = int(input())
res = []
for i in range(r):
	(a, b) = map(int, input().split())
	x_1 = input().split()
	x_max = int(x_1[-1]) - int(x_1[1])
	x_2 = input().split()
	x_max = max(int(x_2[-1]) - int(x_2[1]), x_max)
	y_1 = input().split()
	y_max = int(y_1[-1]) - int(y_1[1])
	y_2 = input().split()
	y_max = max(int(y_2[-1]) - int(y_2[1]), y_max)
	res.append(max(x_max * b, y_max * a))
for i in res:
	print(i)


t = int(input())
area = list()
for i in range(t):
	aux = input().split()
	w = int(aux[0])
	h = int(aux[1])
	aux = input().split()
	b1 = int(aux[-1]) - int(aux[1])
	aux = input().split()
	b2 = int(aux[-1]) - int(aux[1])
	aux = input().split()
	b3 = int(aux[-1]) - int(aux[1])
	aux = input().split()
	b4 = int(aux[-1]) - int(aux[1])
	area.append(max(b1 * h, b2 * h, b3 * w, b4 * w))
for a in area:
	print(a)


for iq in range(int(input())):
	(w, h) = map(int, input().split())
	t1 = list(map(int, input().split()))
	t2 = list(map(int, input().split()))
	g1 = list(map(int, input().split()))
	g2 = list(map(int, input().split()))
	mg = max(g1[-1] - g1[1], g2[-1] - g2[1])
	mt = max(t1[-1] - t1[1], t2[-1] - t2[1])
	print(max(mg * w, mt * h))


import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq

def input():
	return sys.stdin.readline()[:-1]
INF = 10 ** 10

def solve(W, H, X1, X2, Y1, Y2):
	a1 = (max(X1) - min(X1)) * H
	a2 = (max(X2) - min(X2)) * H
	a3 = (max(Y1) - min(Y1)) * W
	a4 = (max(Y2) - min(Y2)) * W
	return max(a1, a2, a3, a4)
T0 = int(input())
for _ in range(T0):
	(W, H) = map(int, input().split())
	X1 = list(map(int, input().split()))[1:]
	X2 = list(map(int, input().split()))[1:]
	Y1 = list(map(int, input().split()))[1:]
	Y2 = list(map(int, input().split()))[1:]
	print(solve(W, H, X1, X2, Y1, Y2))


n = int(input())
lista = []
for i in range(n):
	q = input().split()
	a = input().split()
	a = [int(x) for x in a[1:]]
	c = input().split()
	c = [int(x) for x in c[1:]]
	b = input().split()
	b = [int(x) for x in b[1:]]
	d = input().split()
	d = [int(x) for x in d[1:]]
	x = abs(a[0] - a[-1]) * int(q[1])
	y = abs(c[0] - c[-1]) * int(q[1])
	z = abs(b[0] - b[-1]) * int(q[0])
	w = abs(d[0] - d[-1]) * int(q[0])
	A = max(x, y, z, w)
	print(A)


t = int(input())
for i in range(t):
	(w, h) = map(int, input().split())
	h1 = list(map(int, input().split()))[1:]
	h2 = list(map(int, input().split()))[1:]
	v1 = list(map(int, input().split()))[1:]
	v2 = list(map(int, input().split()))[1:]
	h1 = max(max(h1) - min(h1), max(h2) - min(h2))
	v = max(max(v1) - min(v1), max(v2) - min(v2))
	print(max(v * w, h1 * h))


t = int(input())
for _ in range(t):
	(w, h) = [int(x) for x in input().split()]
	s = []
	min_max = []
	for i in range(4):
		s.append([int(x) for x in input().split()[1:]])
		min_max.append((min(s[-1]), max(s[-1])))
	max_1 = max(min_max[:2], key=lambda x: x[1] - x[0])
	max_2 = max(min_max[2:], key=lambda x: x[1] - x[0])
	print(max((max_1[1] - max_1[0]) * h, (max_2[1] - max_2[0]) * w))


t = int(input())
for i in range(t):
	(h, w) = [int(x) for x in input().split()]
	hor1 = [int(x) for x in input().split()]
	hor2 = [int(x) for x in input().split()]
	hor1 = hor1[1:]
	hor2 = hor2[1:]
	ver1 = [int(x) for x in input().split()]
	ver2 = [int(x) for x in input().split()]
	ver1 = ver1[1:]
	ver2 = ver2[1:]
	hors = []
	vers = []
	hors.append(hor1[len(hor1) - 1] - hor1[0])
	hors.append(hor2[len(hor2) - 1] - hor2[0])
	vers.append(ver1[len(ver1) - 1] - ver1[0])
	vers.append(ver2[len(ver2) - 1] - ver2[0])
	area = max(h * max(vers), w * max(hors))
	print(area)


from sys import setrecursionlimit
from bisect import bisect_left, bisect_right
from collections import deque
from functools import lru_cache, reduce
from heapq import heappush, heappop
from math import sqrt, ceil, floor, log2
T = int(input())

def rl(t=int):
	return list(map(t, input().split()))
for t in range(1, T + 1):
	(w, h) = rl()
	p = []
	fs = {0: lambda x: (x, 0), 1: lambda x: (x, h), 2: lambda y: (0, y), 3: lambda y: (w, y)}
	for l in range(4):
		a = rl()
		k = a[0]
		p.append([fs[l](a[i]) for i in range(1, len(a))])
	best = 0
	for (s, c) in ((0, 1), (1, 0), (2, 3), (3, 2)):
		ps = p[s]
		(po, pt) = (ps[0], ps[-1])
		b = max(pt[0] - po[0], pt[1] - po[1])
		h = 0
		if p[c][0][0] != p[c][1][0]:
			h = abs(p[c][0][1] - po[1])
		else:
			h = abs(p[c][0][0] - po[0])
		best = max(best, b * h)
	print(best)


def solve_test(w, h, points_b, points_t, points_l, points_r):

	def get_val(points, height):
		return abs(points[0] - points[-1]) * height
	largest = max(get_val(points_b, h), get_val(points_t, h), get_val(points_l, w), get_val(points_r, w))
	print(largest)
mode = 'o'
if mode == 'file':
	f = open('input.txt', 'r')

	def read():
		return f.readline()
else:
	read = input
testcases = int(read())
for _ in range(testcases):
	(w, h) = tuple([int(inp) for inp in read().split(' ')])
	points_b = [int(p) for p in read().split(' ')[1:]]
	points_t = [int(p) for p in read().split(' ')[1:]]
	points_l = [int(p) for p in read().split(' ')[1:]]
	points_r = [int(p) for p in read().split(' ')[1:]]
	solve_test(w, h, points_b, points_t, points_l, points_r)
if mode == 'file':
	f.close()


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(w, h) = map(int, input().split())
	x1 = list(map(int, input().split()))
	x2 = list(map(int, input().split()))
	y1 = list(map(int, input().split()))
	y2 = list(map(int, input().split()))
	print(max(max(x1[-1] - x1[1], x2[-1] - x2[1]) * h, max(y1[-1] - y1[1], y2[-1] - y2[1]) * w))


import math
import os
import sys
from io import BytesIO, IOBase
M = 1000000007
import random
import heapq
import threading
import bisect
import time
from functools import *
from collections import *
from itertools import *
BUFSIZE = 8192
import array

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def fsep():
	return map(float, inp().split())

def inpu():
	return int(inp())

def build(a, b, st, arr, node):
	if a == b:
		st[node] = arr[a]
		return arr[a]
	mid = (a + b) // 2
	p = build(a, mid, st, arr, 2 * node + 1)
	q = build(mid + 1, b, st, arr, 2 * node + 2)
	st[node] = p + q
	return st[node]

def update(st, a, b, x, val, node):
	if x < a or x > b:
		return
	st[node] = st[node] + val
	if a != b:
		mid = (a + b) // 2
		update(st, a, mid, x, val, 2 * node + 1)
		update(st, mid + 1, b, x, val, 2 * node + 2)

def getsum(st, a, b, l, r, node):
	if l > b or r < a:
		return 0
	if l <= a and r >= b:
		return st[node]
	mid = (a + b) // 2
	return getsum(st, a, mid, l, r, 2 * node + 1) + getsum(st, mid + 1, b, l, r, 2 * node + 2)

def dfs2(curr, parent, start, end, cnt, res, d, arr):
	res[cnt[0]] = arr[curr - 1]
	start[curr] = cnt[0]
	cnt[0] += 1
	for i in d[curr]:
		if i != parent:
			dfs2(i, curr, start, end, cnt, res, d, arr)
			cnt[0] += 1
	res[cnt[0]] = arr[curr - 1]
	end[curr] = cnt[0]

def main():
	tt = 1
	tt = inpu()
	for _ in range(tt):
		(w, h) = sep()
		a = lis()
		b = lis()
		c = lis()
		d = lis()
		a.pop(0)
		b.pop(0)
		c.pop(0)
		d.pop(0)
		area1 = (a[-1] - a[0]) * h
		area2 = (b[-1] - b[0]) * h
		area3 = (c[-1] - c[0]) * w
		area4 = (d[-1] - d[0]) * w
		print(max(area1, area2, area3, area4))
main()


def solve():
	(w, h) = [int(x) for x in input().split()]
	ret = 0
	H = [h, h, w, w]
	for h in H:
		A = [int(x) for x in input().split()]
		ret = max(ret, h * (A[-1] - A[1]))
	print(ret)
t = int(input())
for _ in range(t):
	solve()


t = int(input())
for _ in range(t):
	(w, h) = map(int, input().split())
	x1 = list(map(int, input().split()))
	x2 = list(map(int, input().split()))
	y1 = list(map(int, input().split()))
	y2 = list(map(int, input().split()))
	a1 = h * (x1[-1] - x1[1])
	a2 = h * (x2[-1] - x2[1])
	a3 = w * (y1[-1] - y1[1])
	a4 = w * (y2[-1] - y2[1])
	print(max(a1, a2, a3, a4))


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
from collections import Counter
t = inp()
for _ in range(t):
	(w, h) = invr()
	A = inlt()
	B = inlt()
	C = inlt()
	D = inlt()
	print(max(max(A[-1] - A[1], B[-1] - B[1]) * h, max(C[-1] - C[1], D[-1] - D[1]) * w))


def solve(h, w, l1, l2, l3, l4):
	a1 = (l1[-1] - l1[1]) * h
	a2 = (l2[-1] - l2[1]) * h
	a3 = (l3[-1] - l3[1]) * w
	a4 = (l4[-1] - l4[1]) * w
	return max(a1, a2, a3, a4)

def main():
	t = int(input())
	for _ in range(t):
		(w, h) = map(int, input().split())
		l1 = list(map(int, input().split()))
		l2 = list(map(int, input().split()))
		l3 = list(map(int, input().split()))
		l4 = list(map(int, input().split()))
		print(solve(h, w, l1, l2, l3, l4))
main()


for _ in range(int(input())):
	(w, h) = map(int, input().split())
	a = list(map(int, input().split()))[1:]
	b = list(map(int, input().split()))[1:]
	c = list(map(int, input().split()))[1:]
	d = list(map(int, input().split()))[1:]
	u = max(a[-1] - a[0], b[-1] - b[0]) * h
	v = max(c[-1] - c[0], d[-1] - d[0]) * w
	print(max(u, v))


t = int(input())
for test_case in range(t):
	(w, h) = map(int, input().split())
	x_firstLine = list(map(int, input().split()))
	x_secondLine = list(map(int, input().split()))
	y_firstLine = list(map(int, input().split()))
	y_secondLine = list(map(int, input().split()))
	x_firstLine_distance = x_firstLine[-1] - x_firstLine[1]
	x_secondLine_distance = x_secondLine[-1] - x_secondLine[1]
	y_firstLine_distance = y_firstLine[-1] - y_firstLine[1]
	y_secondLine_distance = y_secondLine[-1] - y_secondLine[1]
	if x_firstLine_distance > x_secondLine_distance:
		highest_distance_x = x_firstLine_distance
	else:
		highest_distance_x = x_secondLine_distance
	if y_firstLine_distance > y_secondLine_distance:
		highest_distance_y = y_firstLine_distance
	else:
		highest_distance_y = y_secondLine_distance
	Area_1 = highest_distance_x * h
	Area_2 = highest_distance_y * w
	if Area_1 > Area_2:
		print(Area_1)
	else:
		print(Area_2)


def area(b, h):
	area = 0.5 * b * h
	return area

def greater(a, b):
	if a > b:
		return a
	else:
		return b
t = int(input())
fl = []
for i in range(0, t):
	(w, h) = map(int, input().split())
	x1 = list(map(int, input().split()))
	x2 = list(map(int, input().split()))
	y1 = list(map(int, input().split()))
	y2 = list(map(int, input().split()))
	dx1 = x1[x1[0]] - x1[1]
	dx2 = x2[x2[0]] - x2[1]
	dy1 = y1[y1[0]] - y1[1]
	dy2 = y2[y2[0]] - y2[1]
	base = greater(dx1, dx2)
	xarea = area(base, h)
	height = greater(dy1, dy2)
	yarea = area(w, height)
	farea = greater(xarea, yarea)
	fl.append(farea * 2)
for i in fl:
	print(int(i))


t = int(input())
for i in range(t):
	(w, h) = map(int, input().split())
	x1 = list(map(int, input().split()))
	x2 = list(map(int, input().split()))
	y1 = list(map(int, input().split()))
	y2 = list(map(int, input().split()))
	x1 = x1[1:]
	x2 = x2[1:]
	y1 = y1[1:]
	y2 = y2[1:]
	a1 = (max(x1) - min(x1)) * h
	a2 = (max(x2) - min(x2)) * h
	a3 = (max(y1) - min(y1)) * w
	a4 = (max(y2) - min(y2)) * w
	arr = [a1, a2, a3, a4]
	print(max(arr))


for _ in range(int(input())):
	(w, h) = [int(e) for e in input().split()]
	(_, *x1) = [(int(e), 0) for e in input().split()]
	(_, *x2) = [(int(e), h) for e in input().split()]
	(_, *y1) = [(0, int(e)) for e in input().split()]
	(_, *y2) = [(w, int(e)) for e in input().split()]
	x1 = sorted(x1, key=lambda x: x[0])
	x2 = sorted(x2, key=lambda x: x[0])
	y1 = sorted(y1, key=lambda x: x[1])
	y2 = sorted(y2, key=lambda x: x[1])
	md = max((x1[-1][0] - x1[0][0]) * h, (x2[-1][0] - x2[0][0]) * h, (y1[-1][1] - y1[0][1]) * w, (y2[-1][1] - y2[0][1]) * w)
	print(md)


import sys
import math
from bisect import bisect_right as br
from collections import deque
from itertools import combinations as cb

def int_arr():
	return list(map(int, sys.stdin.readline().strip().split()))

def str_arr():
	return list(map(str, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	(w, h) = int_arr()
	x1 = int_arr()
	x2 = int_arr()
	y1 = int_arr()
	y2 = int_arr()
	ans = max((x1[-1] - x1[1]) * h, (x2[-1] - x2[1]) * h, (y2[-1] - y2[1]) * w, (y1[-1] - y1[1]) * w)
	print(ans)


from math import *
from bisect import bisect_left as bl
from bisect import bisect_right as br
from collections import Counter as ctr
from collections import deque as dq
from array import array
from re import search
li = lambda : list(map(int, input().split()))
arr = lambda a: array('i', a)
bi = lambda n: bin(n).replace('0b', '')
yn = lambda f: print('NYOE S'[f::2])
sbstr = lambda a, s: search('.*'.join(a), s)

def dec_to_base(num, base):
	base_num = ''
	while num > 0:
		dig = int(num % base)
		if dig < 10:
			base_num += str(dig)
		else:
			base_num += chr(ord('A') + dig - 10)
		num //= base
	base_num = base_num[::-1]
	return base_num

def solve():
	for _ in range(int(input())):
		(w, h) = li()
		px0 = li()[1:]
		pxh = li()[1:]
		py0 = li()[1:]
		pyw = li()[1:]
		print(max(h * (px0[-1] - px0[0]), h * (pxh[-1] - pxh[0]), w * (py0[-1] - py0[0]), w * (pyw[-1] - pyw[0])))
solve()


import sys
import pprint
import logging
from logging import getLogger

def input():
	return sys.stdin.readline().rstrip('\r\n')
logging.basicConfig(format='%(message)s', level=logging.WARNING)
logger = getLogger(__name__)
logger.setLevel(logging.INFO)

def debug(msg, *args):
	logger.info(f'{msg}={pprint.pformat(args)}')

def inp():
	return map(int, input().split())
from collections import defaultdict

def findArea(a, b, c):
	(ax, ay) = a
	(bx, by) = b
	(cx, cy) = c
	return int(2 * abs((ax * (by - cy) + bx * (cy - ay) + cx * (ay - by)) / 2))

def slv():
	(w, h) = map(int, input().split())
	allpoints = []
	for k in range(2):
		for i in range(2):
			a = list(map(int, input().split()))
			for j in range(1, a[0] + 1):
				if k == 0:
					if i == 0:
						allpoints.append((a[j], 0))
					else:
						allpoints.append((a[j], h))
				elif i == 0:
					allpoints.append((0, a[j]))
				else:
					allpoints.append((w, a[j]))
	dx = defaultdict(list)
	dy = defaultdict(list)
	for (x, y) in allpoints:
		dx[x].append(y)
		dy[y].append(x)
	ans = 0

	def func(f1, f2, xx):
		nonlocal ans
		for x in dx:
			if x == xx:
				continue
			for y in dx[x]:
				f3 = (x, y)
				ans = max(ans, findArea(f1, f2, f3))
	f1 = (0, dx[0][0])
	f2 = (0, dx[0][-1])
	func(f1, f2, 0)
	f1 = (w, dx[w][0])
	f2 = (w, dx[w][-1])
	func(f1, f2, w)

	def func2(f1, f2, yy):
		nonlocal ans
		for y in dy:
			if y == yy:
				continue
			for x in dy[y]:
				f3 = (x, y)
				ans = max(ans, findArea(f1, f2, f3))
	f1 = (dy[0][0], 0)
	f2 = (dy[0][-1], 0)
	func2(f1, f2, 0)
	f1 = (dy[h][0], h)
	f2 = (dy[h][-1], h)
	func2(f1, f2, h)
	print(ans)
for _ in range(*inp()):
	slv()


tests = int(input())
for _ in range(tests):
	(w, h) = map(int, input().split())
	bottoms = list(map(int, input().split()))
	tops = list(map(int, input().split()))
	lefts = list(map(int, input().split()))
	rights = list(map(int, input().split()))
	print(max([(bottoms[-1] - bottoms[1]) * h, (tops[-1] - tops[1]) * h, (lefts[-1] - lefts[1]) * w, (rights[-1] - rights[1]) * w]))


t = int(input())
for p in range(t):
	(w, h) = map(int, input().split())
	lis = []
	for i in range(4):
		lis.append(list(map(int, input().split())))
	ans = 0
	lis = [sorted(i[1:]) for i in lis]
	for i in range(2):
		ans = max(ans, (lis[i][-1] - lis[i][0]) * h)
	for j in range(2, 4):
		ans = max(ans, (lis[j][-1] - lis[j][0]) * w)
	print(ans)


def solve(w, h, horizntale0, horizntaleH, vertical0, verticalW):
	a = (horizntale0[-1] - horizntale0[0]) * h
	b = (horizntaleH[-1] - horizntaleH[0]) * h
	c = (vertical0[-1] - vertical0[0]) * w
	d = (verticalW[-1] - verticalW[0]) * w
	print(max(a, b, c, d))
t = int(input())
for _ in range(t):
	(w, h) = list(map(int, input().strip().split()))
	horizntale0 = list(map(int, input().strip().split()))[1:]
	horizntaleH = list(map(int, input().strip().split()))[1:]
	vertical0 = list(map(int, input().strip().split()))[1:]
	verticalW = list(map(int, input().strip().split()))[1:]
	solve(w, h, horizntale0, horizntaleH, vertical0, verticalW)


t = int(input())
for i in range(t):
	(w, h) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l3 = list(map(int, input().split()))
	l4 = list(map(int, input().split()))
	b = []
	b.append(l1[-1] - l1[1])
	b.append(l2[-1] - l2[1])
	b.append(l3[-1] - l3[1])
	b.append(l4[-1] - l4[1])
	ans = []
	ans.append(h * b[0])
	ans.append(h * b[1])
	ans.append(w * b[2])
	ans.append(w * b[3])
	print(max(ans))


import math

def process(w, h, bottom, top, left, right):
	best = 0
	width = bottom[-1] - bottom[0]
	area = width * h
	best = max(best, area)
	width = -top[0] + top[-1]
	area = width * h
	best = max(best, area)
	width = -left[0] + left[-1]
	area = width * w
	best = max(best, area)
	width = -right[0] + right[-1]
	area = width * w
	best = max(best, area)
	return best

def test():
	for _ in range(int(input())):
		(w, h) = map(int, input().split())
		bottom = list(map(int, input().split()))[1:]
		top = list(map(int, input().split()))[1:]
		left = list(map(int, input().split()))[1:]
		right = list(map(int, input().split()))[1:]
		result = process(w, h, bottom, top, left, right)
		print(result)
test()


def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
t = inp()
for i in range(t):
	(w, h) = invr()
	x1 = inlt()
	x2 = inlt()
	y1 = inlt()
	y2 = inlt()
	l = []
	gx1 = x1[-1] - x1[1]
	l.append(gx1 * h)
	gx2 = x2[-1] - x2[1]
	l.append(gx2 * h)
	gy1 = y1[-1] - y1[1]
	l.append(gy1 * w)
	gy2 = y2[-1] - y2[1]
	l.append(gy2 * w)
	print(max(l))


def area(x1, y1, x2, y2, x3, y3):
	d = abs(x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2))
	return int(d)
T = int(input())
for t in range(T):
	(w, h) = map(int, input().split())
	s1 = list(map(int, input().split()))[1:]
	s2 = list(map(int, input().split()))[1:]
	s3 = list(map(int, input().split()))[1:]
	s4 = list(map(int, input().split()))[1:]
	ans = -1
	(x1, x2) = (s1[0], s1[-1])
	ans = max(area(x1, 0, x2, 0, 0, s3[-1]), ans)
	for x3 in s2:
		ans = max(area(x1, 0, x2, 0, x3, h), ans)
	ans = max(area(x1, 0, x2, 0, w, s4[-1]), ans)
	(x1, x2) = (s2[0], s2[-1])
	ans = max(area(x1, h, x2, h, 0, s3[0]), ans)
	for x3 in s1:
		ans = max(area(x1, h, x2, h, x3, 0), ans)
	ans = max(area(x1, h, x2, h, w, s4[0]), ans)
	(y1, y2) = (s3[0], s3[-1])
	ans = max(area(0, y1, 0, y2, s1[-1], 0), ans)
	for y3 in s4:
		ans = max(area(0, y1, 0, y2, w, y3), ans)
	ans = max(area(0, y1, 0, y2, s2[-1], h), ans)
	(y1, y2) = (s4[0], s4[-1])
	ans = max(area(w, y1, w, y2, s1[0], 0), ans)
	for y3 in s3:
		ans = max(area(w, y1, w, y2, 0, y3), ans)
	ans = max(area(w, y1, w, y2, s2[0], h), ans)
	print(ans)


t = int(input())
for i in range(t):
	a = list(map(int, input().strip().split()))
	x1 = list(map(int, input().strip().split()))
	x2 = list(map(int, input().strip().split()))
	y1 = list(map(int, input().strip().split()))
	y2 = list(map(int, input().strip().split()))
	basemax = max(x1[-1] - x1[1], x2[-1] - x2[1])
	basemax2 = max(y1[-1] - y1[1], y2[-1] - y2[1])
	area1 = basemax * a[1]
	area2 = basemax2 * a[0]
	print(max(area1, area2))


def Area(corners):
	n = len(corners)
	area = 0.0
	for i in range(n):
		j = (i + 1) % n
		area += corners[i][0] * corners[j][1]
		area -= corners[j][0] * corners[i][1]
	area = abs(area) / 2
	return area * 2
for _ in range(int(input())):
	(w, d) = map(int, input().split())
	x1 = list(map(int, input().split()))[1:]
	x2 = list(map(int, input().split()))[1:]
	y1 = list(map(int, input().split()))[1:]
	y2 = list(map(int, input().split()))[1:]
	if 0 in x1:
		x1.remove(0)
	if w in x1:
		x1.remove(w)
	if 0 in x2:
		x2.remove(0)
	if w in x2:
		x2.remove(w)
	if 0 in y1:
		y1.remove(0)
	if d in y1:
		y1.remove(d)
	if 0 in y2:
		y2.remove(0)
	if d in y2:
		y2.remove(d)
	xl1 = []
	xl2 = []
	yl1 = []
	yl2 = []
	for i in x1:
		xl1.append((i, 0))
	for j in x2:
		xl2.append((j, d))
	for k in y1:
		yl1.append((0, k))
	for l in y2:
		yl2.append((w, l))
	n = [max(xl1), max(xl2), max(yl1), max(yl2), min(xl1), min(xl2), min(yl1), min(yl2)]
	m = [(max(xl1), min(xl1)), (max(xl2), min(xl2)), (max(yl1), min(yl1)), (max(yl2), min(yl2))]
	ans = 0
	for h in m:
		h1 = h[0]
		h2 = h[1]
		for p in n:
			ar = Area([h1, h2, p])
			if ar > ans:
				ans = ar
	print(int(ans))


for t in range(int(input())):
	(w, h) = map(int, input().split())
	ans = 0
	for i in range(4):
		arr = list(map(int, input().split()))[1:]
		ans = max(ans, (arr[-1] - arr[0]) * (h if i < 2 else w))
	print(ans)


def solve(array, dim):
	base_x1 = array[0][-1] - array[0][0]
	base_x2 = array[1][-1] - array[1][0]
	base_y1 = array[2][-1] - array[2][0]
	base_y2 = array[3][-1] - array[3][0]
	max_area = max(base_x1 * dim[1], base_x2 * dim[1], base_y1 * dim[0], base_y2 * dim[0])
	print(max_area)
t = int(input())
for test_case in range(t):
	a = list(map(int, input().split()))
	array = []
	for i in range(4):
		array.append(sorted(list(map(int, input().split()))[1:]))
	solve(array, a)


test_cases = int(input())
for i in range(0, test_cases):
	(w, h) = input().split()
	w = int(w)
	h = int(h)
	x0 = input().split()
	x1 = input().split()
	base = int(x0[int(x0[0])]) - int(x0[1])
	top = int(x1[int(x1[0])]) - int(x1[1])
	temp1 = max(base, top) * h
	y0 = input().split()
	y1 = input().split()
	base = int(y0[int(y0[0])]) - int(y0[1])
	top = int(y1[int(y1[0])]) - int(y1[1])
	temp2 = max(base, top) * w
	print(max(temp1, temp2))


I = lambda : list(map(int, input().split()))
for _ in range(int(input())):
	p = I()
	a = [I(), I(), I(), I()]
	x = [0, 0]
	for i in range(2):
		x[i] = max(a[2 * i][-1] - a[2 * i][1], a[2 * i + 1][-1] - a[2 * i + 1][1]) * p[1 - i]
	print(max(x))


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
inp = lambda : list(map(int, sys.stdin.readline().rstrip('\r\n').split()))
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	a = inp()
	b = inp()
	c = inp()
	d = inp()
	print(max((a[-1] - a[1]) * y, (b[-1] - b[1]) * y, (c[-1] - c[1]) * x, (d[-1] - d[1]) * x))


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def inlt_s():
	return list(input().strip())
from collections import defaultdict
import copy
import math

class Solution:

	def solve(self, inp, w, h):
		(A, B, C, D) = inp
		base1 = int(A[-1]) - int(A[1])
		height1 = h
		base2 = int(B[-1]) - int(B[1])
		height2 = h
		base3 = int(C[-1]) - int(C[1])
		height3 = w
		base4 = int(D[-1]) - int(D[1])
		height4 = w
		return max(base1 * height1, base2 * height2, base3 * height3, base4 * height4)
t = inp()
OB = Solution()
for j in range(t):
	(w, h) = invr()
	inp = []
	for i in range(4):
		lst = inlt()
		inp.append(lst)
	sol = OB.solve(inp, w, h)
	print(sol)


t = int(input())
ans = []
for i in range(t):
	(w, h) = map(int, input().split())
	a = list(map(int, input().split()))[1:]
	(dmin, dmax) = (min(a), max(a))
	a = list(map(int, input().split()))[1:]
	(umin, umax) = (min(a), max(a))
	a = list(map(int, input().split()))[1:]
	(lmin, lmax) = (min(a), max(a))
	a = list(map(int, input().split()))[1:]
	(rmin, rmax) = (min(a), max(a))
	temp = max((dmax - dmin) * h, (umax - umin) * h, (lmax - lmin) * w, (rmax - rmin) * w)
	ans.append(temp)
print(*ans, sep='\n')


import sys
input = sys.stdin.readline

def get_line():
	array = list(map(int, input().split()))
	array.pop(0)
	return array
for _ in range(int(input())):
	(w, h) = map(int, input().split())
	horizontal_1 = get_line()
	horizontal_2 = get_line()
	vertical_1 = get_line()
	vertical_2 = get_line()
	horizontal_area_1 = (max(horizontal_1) - min(horizontal_1)) * h
	horizontal_area_2 = (max(horizontal_2) - min(horizontal_2)) * h
	vertical_area_1 = (max(vertical_1) - min(vertical_1)) * w
	vertical_area_2 = (max(vertical_2) - min(vertical_2)) * w
	print(max(horizontal_area_1, horizontal_area_2, vertical_area_1, vertical_area_2))


t = int(input())
for _ in range(t):
	(w, h) = map(int, input().split())
	s1 = list(map(int, input().split()))
	s2 = list(map(int, input().split()))
	stol1 = list(map(int, input().split()))
	stol2 = list(map(int, input().split()))
	m = max((s1[-1] - s1[1]) * h, (s2[-1] - s2[1]) * h, (stol1[-1] - stol1[1]) * w, (stol2[-1] - stol2[1]) * w)
	print(m)


t = int(input())
for i in range(t):
	(w, h) = map(int, input().split())
	res = 0
	for _ in range(4):
		ls = [int(x) for x in input().split()][1:]
		res = max(res, (ls[-1] - ls[0]) * (w if _ > 1 else h))
	print(res)


for _ in range(int(input())):
	(w, h) = map(int, input().split())
	(_, *hor_b) = map(int, input().split())
	(_, *hor_r) = map(int, input().split())
	(_, *ver_b) = map(int, input().split())
	(_, *ver_r) = map(int, input().split())
	A1 = h * (max(hor_b) - min(hor_b))
	A2 = h * (max(hor_r) - min(hor_r))
	A3 = w * (max(ver_b) - min(ver_b))
	A4 = w * (max(ver_r) - min(ver_r))
	print(max(A1, A2, A3, A4))


test = int(input())
for t in range(test):
	l = list(map(int, input().split()))
	(w, h) = (l[0], l[1])
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l3 = list(map(int, input().split()))
	l4 = list(map(int, input().split()))
	(x1, x2) = (h * abs(l1[1] - l1[len(l1) - 1]), h * abs(l2[1] - l2[len(l2) - 1]))
	(y1, y2) = (w * abs(l3[1] - l3[len(l3) - 1]), w * abs(l4[1] - l4[len(l4) - 1]))
	c = max(max(x1, x2), max(y1, y2))
	print(c)


t = int(input())
for i in range(t):
	(w, h) = input().split()
	(w, h) = (int(w), int(h))
	w1x = []
	w1x = [int(item) for item in input().split()]
	w1h = [int(item) for item in input().split()]
	h1y = [int(item) for item in input().split()]
	h1w = [int(item) for item in input().split()]
	max_w1x = max(w1x[1:]) - min(w1x[1:])
	max_w1h = max(w1h[1:]) - min(w1h[1:])
	max_h1y = max(h1y[1:]) - min(h1y[1:])
	max_h1w = max(h1w[1:]) - min(h1w[1:])
	print(max(max_w1x * h, max_w1h * h, max_h1y * w, max_h1w * w))


t = int(input())
result = []
while t:
	(w, h) = list(map(int, input().split()))
	x1 = list(map(int, input().split()))[1:]
	x2 = list(map(int, input().split()))[1:]
	y1 = list(map(int, input().split()))[1:]
	y2 = list(map(int, input().split()))[1:]
	aire_1 = (x1[-1] - x1[0]) * h
	aire_2 = (x2[-1] - x2[0]) * h
	aire_3 = (y1[-1] - y1[0]) * w
	aire_4 = (y2[-1] - y2[0]) * w
	result.append(max(aire_1, aire_2, aire_3, aire_4))
	t -= 1
for x in result:
	print(x)


for _ in range(int(input())):
	(w, h) = map(int, input().split())
	l = [h, w]
	area = 0
	for i in range(4):
		x = list(map(int, input().split()))
		area = max(area, (x[-1] - x[1]) * l[i // 2])
	print(area)


def main():
	t = int(input())
	for tt in range(t):
		(w, h) = [int(x) for x in input().split()]
		d_area = []
		height = [h, h, w, w]
		for i in range(4):
			line = [int(x) for x in input().split()]
			d_area.append(height[i] * (line[-1] - line[1]))
		print(max(d_area))
main()


for u in range(int(input())):
	(w, h) = map(int, input().split())
	(a, b, c, d) = (list(map(int, input().split())), list(map(int, input().split())), list(map(int, input().split())), list(map(int, input().split())))
	(a, b, c, d) = (a[1:len(a)], b[1:len(b)], c[1:len(c)], d[1:len(d)])
	a.sort()
	b.sort()
	c.sort()
	d.sort()
	print(max((a[-1] - a[0]) * h, (b[-1] - b[0]) * h, (c[-1] - c[0]) * w, (d[-1] - d[0]) * w))


R = lambda : list(map(int, input().split()))
(TC,) = R()
while TC:
	A = []
	TC = TC - 1
	(w, h) = R()
	l1 = R()[1:]
	l2 = R()[1:]
	l3 = R()[1:]
	l4 = R()[1:]
	MH = max(l3 + l4)
	MW = max(l1 + l2)
	A.append((max(l1) - min(l1)) * max(MH, h))
	A.append((max(l2) - min(l2)) * max(abs(MH - h), h))
	A.append((max(l3) - min(l3)) * max(MW, w))
	A.append((max(l4) - min(l4)) * max(abs(MW - w), w))
	print(max(A))


k = int(input())
for _ in range(k):
	(w, h) = [int(x) for x in input().split()]
	x1 = sorted([int(x) for x in input().split()][1:])
	x2 = sorted([int(x) for x in input().split()][1:])
	y1 = sorted([int(x) for x in input().split()][1:])
	y2 = sorted([int(x) for x in input().split()][1:])
	a = max(h * (x1[-1] - x1[0]), h * (x2[-1] - x2[0]), w * (y1[-1] - y1[0]), w * (y2[-1] - y2[0]))
	print(a)


def main():
	t = int(input())
	allans = []
	for _ in range(t):
		(w, h) = readIntArr()
		x_with_y0 = readIntArr()[1:]
		x_with_yh = readIntArr()[1:]
		y_with_x0 = readIntArr()[1:]
		y_with_xw = readIntArr()[1:]
		ans = max(h * max(x_with_y0[-1] - x_with_y0[0], x_with_yh[-1] - x_with_yh[0]), w * max(y_with_x0[-1] - y_with_x0[0], y_with_xw[-1] - y_with_xw[0]))
		allans.append(ans)
	multiLineArrayPrint(allans)
	return
import sys
input = sys.stdin.buffer.readline

def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def multiLineArrayPrint(arr):
	print('\n'.join([str(x) for x in arr]))

def multiLineArrayOfArraysPrint(arr):
	print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

def readIntArr():
	return [int(x) for x in input().split()]

def makeArr(defaultValFactory, dimensionArr):
	dv = defaultValFactory
	da = dimensionArr
	if len(da) == 1:
		return [dv() for _ in range(da[0])]
	else:
		return [makeArr(dv, da[1:]) for _ in range(da[0])]

def queryInteractive(a, b, c):
	print('? {} {} {}'.format(a, b, c))
	sys.stdout.flush()
	return int(input())

def answerInteractive(ansArr):
	print('! {}'.format(' '.join([str(x) for x in ansArr])))
	sys.stdout.flush()
inf = float('inf')
from math import gcd, floor, ceil
import math
for _abc in range(1):
	main()


from sys import stdin
Liste = stdin.read().split('\n')
for i in range(0, int(Liste[0])):
	w = int(Liste[5 * i + 1].split()[0])
	h = int(Liste[5 * i + 1].split()[1])
	x = max(int(Liste[5 * i + 2].split()[-1]) - int(Liste[5 * i + 2].split()[1]), int(Liste[5 * i + 3].split()[-1]) - int(Liste[5 * i + 3].split()[1]))
	y = max(int(Liste[5 * i + 4].split()[-1]) - int(Liste[5 * i + 4].split()[1]), int(Liste[5 * i + 5].split()[-1]) - int(Liste[5 * i + 5].split()[1]))
	print(max(x * h, y * w))


from itertools import permutations as per
from math import factorial as fact
from difflib import SequenceMatcher
t = int(input())
for _ in range(t):
	(w, h) = map(int, input().split())
	x1 = [int(i) for i in input().split()]
	x2 = [int(i) for i in input().split()]
	y1 = [int(i) for i in input().split()]
	y2 = [int(i) for i in input().split()]
	a1 = (x1[-1] - x1[1]) * h
	a2 = (x2[-1] - x2[1]) * h
	a3 = (y1[-1] - y1[1]) * w
	a4 = (y2[-1] - y2[1]) * w
	print(max(a1, a2, a3, a4))


for _ in range(int(input())):
	(w, h) = map(int, input().split())
	a = list(map(int, input().split()))[1:]
	b = list(map(int, input().split()))[1:]
	c = list(map(int, input().split()))[1:]
	d = list(map(int, input().split()))[1:]
	max_a = a[-1] - a[0]
	max_b = b[-1] - b[0]
	max_c = c[-1] - c[0]
	max_d = d[-1] - d[0]
	print(max(max_a * h, max_b * h, max_c * w, max_d * w))


t = int(input())
for i in range(t):
	(w, h) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l3 = list(map(int, input().split()))
	l4 = list(map(int, input().split()))
	b1 = l1[-1] - l1[1]
	b2 = l2[-1] - l2[1]
	b3 = l3[-1] - l3[1]
	b4 = l4[-1] - l4[1]
	if b1 > b2:
		r1 = b1 * h
	else:
		r1 = b2 * h
	if b3 > b4:
		r2 = b3 * w
	else:
		r2 = b4 * w
	print(max(r1, r2))


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	ans = 0
	for i in range(4):
		l = list(map(int, input().split()))
		if i < 2:
			ans = max(ans, (l[-1] - l[1]) * y)
		else:
			ans = max(ans, (l[-1] - l[1]) * x)
	print(ans)


for i in range(int(input())):
	(x, y) = tuple(map(int, input().split()))
	xl = list(map(int, input().split()))
	xu = list(map(int, input().split()))
	yl = list(map(int, input().split()))
	yu = list(map(int, input().split()))
	a = (xl[-1] - xl[1]) * y
	b = (xu[-1] - xu[1]) * y
	c = (yl[-1] - yl[1]) * x
	d = (yu[-1] - yu[1]) * x
	print(max(a, b, c, d))


t = int(input())
l = [0] * t
for i in range(t):
	(w, h) = map(int, input().split())
	(h1, h2, v1, v2) = [sorted(list(map(int, input().split()))[1:]) for j in range(4)]
	l[i] = max((v1[-1] - v1[0]) * w, (v2[-1] - v2[0]) * w, (h1[-1] - h1[0]) * h, (h2[-1] - h2[0]) * h)
for i in l:
	print(i)


t = int(input())
for _ in range(t):
	(w, h) = map(int, input().split())
	w1 = list(map(int, input().strip().split()))
	w2 = list(map(int, input().strip().split()))
	h1 = list(map(int, input().strip().split()))
	h2 = list(map(int, input().strip().split()))
	s1 = max(w2[-1] - w2[1], w1[-1] - w1[1])
	a1 = s1 * h
	s2 = max(h2[-1] - h2[1], h1[-1] - h1[1])
	a2 = s2 * w
	print(max(a1, a2))


def solution():
	(w, h) = map(int, input().split())
	ay0 = [int(x) for x in input().split()]
	ayh = [int(x) for x in input().split()]
	ax0 = [int(x) for x in input().split()]
	axw = [int(x) for x in input().split()]
	return max([(-ay0[1] + ay0[-1]) * h, (-ayh[1] + ayh[-1]) * h, (-ax0[1] + ax0[-1]) * w, (-axw[1] + axw[-1]) * w])
t = int(input())
for _ in range(t):
	print(solution())


for t in range(int(input())):
	(w, h) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l3 = list(map(int, input().split()))
	l4 = list(map(int, input().split()))
	print(max(h * (l1[-1] - l1[1]), h * (l2[-1] - l2[1]), w * (l3[-1] - l3[1]), w * (l4[-1] - l4[1])))


n = int(input())
for i in range(n):
	(w, h) = list(map(int, input().split()))
	a = list(map(int, input().split()))[1:]
	a1 = list(map(int, input().split()))[1:]
	b = list(map(int, input().split()))[1:]
	b1 = list(map(int, input().split()))[1:]
	print(max(h * (max(a) - min(a)), h * (max(a1) - min(a1)), w * (max(b) - min(b)), w * (max(b1) - min(b1))))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	a1 = list(map(int, input().split()))
	a2 = list(map(int, input().split()))
	a3 = list(map(int, input().split()))
	a4 = list(map(int, input().split()))
	res1 = res2 = res3 = res4 = 0
	if len(a1) > 2:
		res1 = abs(a1[1] - a1[-1]) * b
	if len(a2) > 2:
		res2 = abs(a2[1] - a2[-1]) * b
	if len(a3) > 2:
		res3 = abs(a3[1] - a3[-1]) * a
	if len(a4) > 2:
		res4 = abs(a4[1] - a4[-1]) * a
	print(max(res1, res2, res3, res4))


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	(w, h) = map(int, stdin.readline().split())
	h1 = list(map(int, stdin.readline().split()))
	h2 = list(map(int, stdin.readline().split()))
	v1 = list(map(int, stdin.readline().split()))
	v2 = list(map(int, stdin.readline().split()))
	h1[1:].sort()
	h2[1:].sort()
	v1[1:].sort()
	v2[1:].sort()
	print(max(h * (h1[-1] - h1[1]), h * (h2[-1] - h2[1]), w * (v1[-1] - v1[1]), w * (v2[-1] - v2[1])))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	x1 = list(map(int, input().split()))
	x2 = list(map(int, input().split()))
	y1 = list(map(int, input().split()))
	y2 = list(map(int, input().split()))
	a1 = x1[-1] - x1[1]
	a2 = x2[-1] - x2[1]
	x = max(a1, a2)
	a1 = y1[-1] - y1[1]
	a2 = y2[-1] - y2[1]
	y = max(a1, a2)
	print(max(y * n, x * m))


def solve(A, B, C, D, w, h):
	a = max(A) - min(A)
	b = max(B) - min(B)
	c = max(C) - min(C)
	d = max(D) - min(D)
	m1 = max(a, b)
	m2 = max(c, d)
	return max(m1 * h, m2 * w)
for _ in range(int(input())):
	(w, h) = map(int, input().split(' '))
	A = list(map(int, input().split(' ')))[1:]
	B = list(map(int, input().split(' ')))[1:]
	C = list(map(int, input().split(' ')))[1:]
	D = list(map(int, input().split(' ')))[1:]
	print(solve(A, B, C, D, w, h))


import sys
import bisect
from bisect import bisect_left as lb
from bisect import bisect_right as rb
input_ = lambda : sys.stdin.readline().strip('\r\n')
from math import log
from math import gcd
from math import atan2, acos
from random import randint
sa = lambda : input_()
sb = lambda : int(input_())
sc = lambda : input_().split()
sd = lambda : list(map(int, input_().split()))
sflo = lambda : list(map(float, input_().split()))
se = lambda : float(input_())
sf = lambda : list(input_())
flsh = lambda : sys.stdout.flush()
sys.setrecursionlimit(3 * 10 ** 5)
mod = 10 ** 9 + 7
mod1 = 998244353
gp = []
cost = []
dp = []
mx = []
ans1 = []
ans2 = []
special = []
specnode = []
a = 0
kthpar = []

def dfs2(root, par):
	if par != -1:
		dp[root] = dp[par] + 1
	for i in range(1, 20):
		if kthpar[root][i - 1] != -1:
			kthpar[root][i] = kthpar[kthpar[root][i - 1]][i - 1]
	for child in gp[root]:
		if child == par:
			continue
		kthpar[child][0] = root
		dfs(child, root)
ans = 0
a = []
(n, k) = (0, 0)
b = []
vis = []
tot = 0
time = []
time1 = []
adj = []
mx = -1
eps = 1e-07
x = 0
pref = []
lvl = []
gp = []
ans = []
f = 0
w = []

def dfs(i, prod, rem, n):
	if rem == 0:
		while i < len(n):
			prod *= int(n[i])
			i += 1
		return prod
	if i == len(n):
		return prod
	mx = 0
	for j in range(9 - int(n[i])):
		mx = max(dfs(i + 1, (int(n[i]) + min(j, rem)) * prod, rem - min(j, rem), n), mx)
	return mx

class Disjoint_SU:

	def __init__(self, n):
		self.parent = [i for i in range(n)]
		self.size = [1 for i in range(n)]

	def lake_de(self, a):
		if a == self.parent[a]:
			return a
		self.parent[a] = self.lake_de(self.parent[a])
		return self.parent[a]

	def jod(self, a, b):
		x = self.lake_de(a)
		y = self.lake_de(b)
		if x == y:
			return True
		if self.size[x] > self.size[y]:
			self.size[x] += self.size[y]
			self.parent[y] = x
		else:
			self.size[y] += self.size[x]
			self.parent[x] = y
		return False
ans = 0
(h, w) = (0, 0)

def func(x1, y1, x2, y2, first, second, third, fourth):
	global ans, h, w
	for i in range(1, len(first)):
		(x3, y3) = (first[i], 0)
		ans = max(ans, x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2))
	for i in range(1, len(second)):
		(x3, y3) = (second[i], h)
		ans = max(ans, x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2))
	for i in range(1, len(third)):
		(x3, y3) = (0, third[i])
		ans = max(ans, x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2))
	for i in range(1, len(fourth)):
		(x3, y3) = (w, fourth[i])
		ans = max(ans, x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2))
	return

def hnbhai(tc):
	global ans, h, w
	ans = 0
	(x, y) = (0, 0)
	(w, h) = sd()
	first = sd()
	second = sd()
	third = sd()
	fourth = sd()
	ans = first[-1] - first[1]
	ans *= h
	ans = max(ans, h * (second[-1] - second[1]))
	ans = max(ans, w * (third[-1] - third[1]), w * (fourth[-1] - fourth[1]))
	print(ans)
	return
for _ in range(sb()):
	hnbhai(_ + 1)


import heapq
import sys
import math
from collections import deque
from bisect import bisect_left, bisect_right
I = sys.stdin.readline
II = lambda : int(I())
IN = lambda x: map(int, x.split())
FN = lambda x: map(float, x.split())
L = lambda x: list(IN(x))
M = 1000000007
P = print
T = True
F = False
for _ in range(II()):
	(w, h) = IN(I())
	y0 = L(I())
	yh = L(I())
	x0 = L(I())
	xw = L(I())
	a = [w * (x0[-1] - x0[1]), (xw[-1] - xw[1]) * w, h * (yh[-1] - yh[1]), h * (y0[-1] - y0[1])]
	print(max(a))


def check(x, mat, n, m):
	flag = False
	pair = [False] * m
	for i in range(n):
		c = 0
		for j in range(m):
			if mat[i][j] >= x:
				pair[j] = True
				c += 1
		if c > 1:
			flag = True
	if not flag and m > 1:
		return False
	ans = sum(pair)
	if ans == m:
		return True
	return False
import sys

def solve():
	for t in range(int(input())):
		(w, h) = map(int, input().split())
		h1 = list(map(int, input().split()))
		h2 = list(map(int, input().split()))
		v1 = list(map(int, input().split()))
		v2 = list(map(int, input().split()))
		arr = [(h1[-1] - h1[1]) * h, (h2[-1] - h2[1]) * h, (v1[-1] - v1[1]) * w, (v2[-1] - v2[1]) * w]
		print(max(arr))
solve()


a = int(input())
i = 0
while i < a:
	b = list(map(int, input().split(' ')))
	c = list(map(int, input().split(' ')))
	d = list(map(int, input().split(' ')))
	e = list(map(int, input().split(' ')))
	f = list(map(int, input().split(' ')))
	c.pop(0)
	d.pop(0)
	e.pop(0)
	f.pop(0)
	g = (max(c) - min(c)) * b[1]
	h = (max(d) - min(d)) * b[1]
	p = (max(e) - min(e)) * b[0]
	j = (max(f) - min(f)) * b[0]
	print(max(g, h, p, j))
	i = i + 1


t = int(input())
for i in range(t):
	(w, h) = map(int, input().split())
	a1 = list(map(int, input().split()))
	a2 = list(map(int, input().split()))
	a3 = list(map(int, input().split()))
	a4 = list(map(int, input().split()))
	x1 = a1[-1] - a1[1]
	x2 = a2[-1] - a2[1]
	x3 = a3[-1] - a3[1]
	x4 = a4[-1] - a4[1]
	print(max(x1 * h, x2 * h, x3 * w, x4 * w))


for q in range(int(input())):
	(w, h) = map(int, input().split())
	x_coords = list(map(int, input().split()))[1:]
	x_coords2 = list(map(int, input().split()))[1:]
	y_coords = list(map(int, input().split()))[1:]
	y_coords2 = list(map(int, input().split()))[1:]
	ans = []
	base1 = x_coords[-1] - x_coords[0]
	height1 = h
	ans.append(base1 * height1)
	base1 = x_coords2[-1] - x_coords2[0]
	ans.append(base1 * height1)
	base2 = y_coords[-1] - y_coords[0]
	height2 = w
	ans.append(base2 * height2)
	base2 = y_coords2[-1] - y_coords2[0]
	ans.append(base2 * height2)
	print(max(ans))


import sys
input = sys.stdin.readline
T = int(input())
for t in range(T):
	(w, h) = map(int, input().strip().split())
	xo = list(map(int, input().strip().split()))
	xh = list(map(int, input().strip().split()))
	oy = list(map(int, input().strip().split()))
	wy = list(map(int, input().strip().split()))
	ans = 0
	ans = max(ans, (xo[xo[0]] - xo[1]) * h)
	ans = max(ans, (xh[xh[0]] - xh[1]) * h)
	ans = max(ans, (oy[oy[0]] - oy[1]) * w)
	ans = max(ans, (wy[wy[0]] - wy[1]) * w)
	print(ans)


for _ in range(int(input())):
	(w, h) = map(int, input().split())
	hor0 = list(map(int, input().split()))
	horh = list(map(int, input().split()))
	ver0 = list(map(int, input().split()))
	verw = list(map(int, input().split()))
	hor0.pop(0)
	horh.pop(0)
	ver0.pop(0)
	verw.pop(0)
	ah = max(hor0[len(hor0) - 1] - hor0[0], horh[len(horh) - 1] - horh[0]) * h
	av = max(ver0[len(ver0) - 1] - ver0[0], verw[len(verw) - 1] - verw[0]) * w
	print(max(ah, av))


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(w, h) = map(int, input().split())
	left = [int(i) for i in input().split()]
	right = [int(i) for i in input().split()]
	top = [int(i) for i in input().split()]
	bot = [int(i) for i in input().split()]
	max_left = (left[-1] - left[1]) * h
	max_right = (right[-1] - right[1]) * h
	max_top = (top[-1] - top[1]) * w
	max_bot = (bot[-1] - bot[1]) * w
	print(max(max_left, max_right, max_top, max_bot))


import sys
from collections import deque

def g(l, n, f):
	a = 0
	x = n - 1
	while a <= x:
		m = a + (x - a) // 2
		if l[m] == f:
			return m
		elif l[m] > f:
			x = m - 1
		else:
			a = m + 1
	return None

def f(l):
	return l[-1] - l[1]
for _ in range(int(sys.stdin.readline())):
	(w, h) = map(int, sys.stdin.readline().split())
	l1 = list(map(int, sys.stdin.readline().split()))
	l2 = list(map(int, sys.stdin.readline().split()))
	l3 = list(map(int, sys.stdin.readline().split()))
	l4 = list(map(int, sys.stdin.readline().split()))
	l = [h * f(l1), h * f(l2), w * f(l3), w * f(l4)]
	print(max(l))


a = int(input())
side = []
for i in range(a):
	(x, y) = list(map(int, input().split(' ')))
	i1 = list(map(int, input().split(' ')))
	i2 = list(map(int, input().split(' ')))
	i3 = list(map(int, input().split(' ')))
	i4 = list(map(int, input().split(' ')))
	if i1[-1] - i1[1] > i2[-1] - i2[1]:
		p1 = [i1[1], i1[-1]]
	else:
		p1 = [i2[1], i2[-1]]
	if i3[-1] - i3[1] > i4[-1] - i4[1]:
		p2 = [i3[1], i3[-1]]
	else:
		p2 = [i4[1], i4[-1]]
	aa = y * (p1[1] - p1[0])
	bb = x * (p2[1] - p2[0])
	if aa > bb:
		print(aa)
	else:
		print(bb)


for iii in range(int(input())):
	(x, y) = map(int, input().split())
	q1 = list(map(int, input().split()))
	q2 = list(map(int, input().split()))
	q3 = list(map(int, input().split()))
	q4 = list(map(int, input().split()))
	w1 = (q1[1] - q1[-1]) * y * -1
	w2 = (q2[1] - q2[-1]) * y * -1
	w3 = (q3[1] - q3[-1]) * x * -1
	w4 = (q4[1] - q4[-1]) * x * -1
	print(max(w1, w2, w3, w4))


for _ in range(int(input())):
	(w, h) = map(int, input().split())
	x1 = list(map(int, input().split()))
	x2 = list(map(int, input().split()))
	y1 = list(map(int, input().split()))
	y2 = list(map(int, input().split()))
	print(max(max(x1[-1] - x1[1], x2[-1] - x2[1]) * h, max(y1[-1] - y1[1], y2[-1] - y2[1]) * w))


for _ in range(int(input())):
	mx = 0
	(w, h) = list(map(int, input().split()))
	for i in range(4):
		if i == 2:
			h = w
		ar = input().split()
		mx = max(mx, (int(ar[-1]) - int(ar[1])) * h)
	print(mx)


t = int(input())
for z in range(t):
	(w, h) = [int(i) for i in input().split(' ')]
	sol = []
	for i in range(4):
		a = [int(i) for i in input().split(' ')]
		if i < 2:
			sol.append((a[-1] - a[1]) * h)
		elif i >= 2:
			sol.append((a[-1] - a[1]) * w)
	print(max(sol))


cases = int(input())
for i in range(cases):
	line = list(map(int, input().split()))
	(w, h) = (line[0], line[1])
	firstLine = list(map(int, input().split()))
	secondLine = list(map(int, input().split()))
	thirdLine = list(map(int, input().split()))
	fourthLine = list(map(int, input().split()))
	(xbase1, xbase2) = (firstLine[1], firstLine[-1])
	(xbase3, xbase4) = (secondLine[1], secondLine[-1])
	xheight = h
	(ybase1, ybase2) = (thirdLine[1], thirdLine[-1])
	(ybase3, ybase4) = (fourthLine[1], fourthLine[-1])
	yheight = w
	print(max((xbase2 - xbase1) * xheight, (ybase2 - ybase1) * yheight, (xbase4 - xbase3) * xheight, (ybase4 - ybase3) * yheight))


entrada = int(input())
for i in range(entrada):
	dos = [int(x) for x in input().split()]
	stored = 0
	alto = 0
	for m in range(4):
		un = [int(x) for x in input().split()]
		checar = un[-1] - un[1]
		checar = checar * dos[0] if m > 1 else checar * dos[1]
		if checar > stored:
			stored = checar
	print(stored)


t = int(input())
for _ in range(t):
	(w, h) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]
	d = [int(i) for i in input().split()]
	ans = max(h * (a[-1] - a[1]), h * (b[-1] - b[1]), w * (c[-1] - c[1]), w * (d[-1] - d[1]))
	print(ans)


for _ in range(int(input())):
	listt = list(map(int, input().split()))
	w = listt[0]
	h = listt[1]
	x0 = list(map(int, input().split()))
	mexx0 = x0[-1] - x0[1]
	x1 = list(map(int, input().split()))
	mexx1 = x1[-1] - x1[1]
	y0 = list(map(int, input().split()))
	mexy0 = y0[-1] - y0[1]
	y1 = list(map(int, input().split()))
	mexy1 = y1[-1] - y1[1]
	mexx0 = max(mexx0, mexx1)
	mexy0 = max(mexy0, mexy1)
	print(max(mexx0 * h, mexy0 * w))


def main():
	(w, h) = map(int, input().split())
	ans = 0
	arr = list(map(int, input().split()))
	if (arr[-1] - arr[1]) * h > ans:
		ans = (arr[-1] - arr[1]) * h
	arr = list(map(int, input().split()))
	if (arr[-1] - arr[1]) * h > ans:
		ans = (arr[-1] - arr[1]) * h
	arr = list(map(int, input().split()))
	if (arr[-1] - arr[1]) * w > ans:
		ans = (arr[-1] - arr[1]) * w
	arr = list(map(int, input().split()))
	if (arr[-1] - arr[1]) * w > ans:
		ans = (arr[-1] - arr[1]) * w
	return ans
for _ in range(int(input())):
	print(main())


for _ in range(int(input())):
	wh = input().split()
	w = wh[0]
	h = wh[1]
	a = input().split()
	b = input().split()
	c = input().split()
	d = input().split()
	print(max((int(a[-1]) - int(a[1])) * int(h), (int(b[-1]) - int(b[1])) * int(h), (int(c[-1]) - int(c[1])) * int(w), (int(d[-1]) - int(d[1])) * int(w)))


import math
t = int(input())
for i in range(t):
	n = input().split(' ')
	(w, h) = (int(n[0]), int(n[1]))
	x_o = input().split(' ')
	x_h = input().split(' ')
	y_o = input().split(' ')
	y_w = input().split(' ')
	abs1 = int(x_o[-1]) - int(x_o[1])
	abs2 = int(x_h[-1]) - int(x_h[1])
	abs3 = int(y_w[-1]) - int(y_w[1])
	abs4 = int(y_o[-1]) - int(y_o[1])
	area = max(abs1 * h, abs2 * h, abs3 * w, abs4 * w)
	print(area)


t = int(input())
for _ in range(t):
	(w, h) = [int(x) for x in input().split()]
	x1s = [int(x) for x in input().split()][1:]
	x2s = [int(x) for x in input().split()][1:]
	y1s = [int(x) for x in input().split()][1:]
	y2s = [int(x) for x in input().split()][1:]
	maxX1 = (x1s[-1] - x1s[0]) * h
	maxX2 = (x2s[-1] - x2s[0]) * h
	maxY1 = (y1s[-1] - y1s[0]) * w
	maxY2 = (y2s[-1] - y2s[0]) * w
	print(max(maxX1, maxX2, maxY1, maxY2))


import math
nb_cases = int(input())
for case in range(nb_cases):
	(w, h) = [int(x) for x in input().split()]
	x1 = [int(x) for x in input().split()]
	x2 = [int(x) for x in input().split()]
	y1 = [int(x) for x in input().split()]
	y2 = [int(x) for x in input().split()]
	x = max(x1[-1] - x1[1], x2[-1] - x2[1])
	y = max(y1[-1] - y1[1], y2[-1] - y2[1])
	print(max(x * h, y * w))


import sys

def main():
	pass

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def isPrime(n):
	if n == 1:
		return False
	if n == 2 or n == 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(5, root, 6):
			if n % i == 0 or n % (i + 2) == 0:
				return False
		return True

def lts(l):
	s = ''.join(map(str, l))
	return s

def power(x, n):
	res = 1
	while n > 0:
		if n & 1:
			res = res * x
		x = x * x
		n = n >> 1
	return res

def divisors_all(n):
	i = 1
	while i * i <= n:
		if n % i == 0:
			print(i, end=' ')
		i += 1
	while i > 0:
		if n % i == 0:
			print(n // i, end=' ')
		i -= 1

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def prime_factors(n):
	while n % 2 == 0:
		print(2)
		n = n // 2
	while n % 3 == 0:
		print(3)
		n = n // 3
	i = 5
	while i * i <= n:
		while n % i == 0:
			print(i)
			n = n // i
		while n % (i + 2) == 0:
			print(i + 2)
			n = n // (i + 2)
		i += 6
	if n > 3:
		print(n)
mod = int(1000000000.0) + 7

def sinp():
	return sys.stdin.readline().strip()

def zinp():
	return int(input())

def zzinp():
	return map(int, sys.stdin.readline().strip().split())

def llinp():
	return list(map(int, sys.stdin.readline().strip().split()))

def p(xyz):
	print(xyz)

def p2(a, b):
	print(a, b)
for _ in range(zinp()):
	(l, h) = zzinp()
	l1 = llinp()
	l2 = llinp()
	l3 = llinp()
	l4 = llinp()
	a = b = c = d = 0
	if len(l1) > 2:
		a = abs(l1[1] - l1[-1]) * h
	if len(l2) > 1:
		b = abs(l2[1] - l2[-1]) * h
	if len(l3) > 1:
		c = abs(l3[1] - l3[-1]) * l
	if len(l4) > 1:
		d = abs(l4[1] - l4[-1]) * l
	print(max(a, b, c, d))


from sys import stdin
input = stdin.readline

def func():
	width = 0
	width = max(width, x_up[-1] - x_up[0])
	width = max(width, x_down[-1] - x_down[0])
	area = width * h
	height = 0
	height = max(height, y_left[-1] - y_left[0])
	height = max(height, y_right[-1] - y_right[0])
	area = max(area, height * w)
	print(area)
for _ in range(int(input())):
	(w, h) = map(int, input().split())
	x_down = list(map(int, input().split()))[1:]
	x_up = list(map(int, input().split()))[1:]
	y_left = list(map(int, input().split()))[1:]
	y_right = list(map(int, input().split()))[1:]
	func()


t = int(input())
for k in range(t):
	s = input().split(' ')
	(w, h) = list(map(int, s))
	h1 = input().split(' ')
	h2 = input().split(' ')
	v1 = input().split(' ')
	v2 = input().split(' ')
	baseh = max(int(h1[-1]) - int(h1[1]), int(h2[-1]) - int(h2[1]))
	basev = max(int(v1[-1]) - int(v1[1]), int(v2[-1]) - int(v2[1]))
	print(max(baseh * h, basev * w))


t = int(input())
for _ in range(0, t):
	(w, h) = map(int, input().split())
	a = list(map(int, input().split()))
	a.remove(a[0])
	b = list(map(int, input().split()))
	b.remove(b[0])
	c = list(map(int, input().split()))
	c.remove(c[0])
	d = list(map(int, input().split()))
	d.remove(d[0])
	a_max = max(a)
	a_min = min(a)
	b_max = max(b)
	b_min = min(b)
	c_max = max(c)
	c_min = min(c)
	d_max = max(d)
	d_min = min(d)
	i = a_max - a_min
	j = b_max - b_min
	k = c_max - c_min
	l = d_max - d_min
	e = []
	x = i * h
	e.append(x)
	y = j * h
	e.append(y)
	z = k * w
	e.append(z)
	h = l * w
	e.append(h)
	print(max(e))


for _ in range(int(input())):
	sides = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	area = max((a[-1] - a[1]) * sides[1], (b[-1] - b[1]) * sides[1], (c[-1] - c[1]) * sides[0], (d[-1] - d[1]) * sides[0])
	print(area)


import sys
import re
import math
from math import log2 as lg
from collections import deque
import random
import heapq
import itertools
const = 1000000007
ep = 1e-08
n = int(input())
for i in range(n):
	line = list(map(int, input().split()))
	(w, h) = (line[0], line[1])
	best = 0
	for j in range(4):
		curr = list(map(int, input().split()))
		if j == 0 or j == 1:
			best = max(best, (curr[-1] - curr[1]) * h)
		else:
			best = max(best, (curr[-1] - curr[1]) * w)
	print(best)


def ans(S1, S2, S3, S4, w, h):
	return max(max(max(S1) - min(S1), max(S2) - min(S2)) * h, max(max(S3) - min(S3), max(S4) - min(S4)) * w)
for _ in range(int(input())):
	(w, h) = map(int, input().split(' '))
	S1 = list(map(int, input().split(' ')))[1:]
	S2 = list(map(int, input().split(' ')))[1:]
	S3 = list(map(int, input().split(' ')))[1:]
	S4 = list(map(int, input().split(' ')))[1:]
	print(ans(S1, S2, S3, S4, w, h))


import sys
from itertools import permutations
n = int(sys.stdin.readline().rstrip('\n'))
for _ in range(n):
	(w, h) = list(map(int, sys.stdin.readline().rstrip('\n').split(' ')))
	x1 = list(map(int, sys.stdin.readline().rstrip('\n').split(' ')))
	x2 = list(map(int, sys.stdin.readline().rstrip('\n').split(' ')))
	y1 = list(map(int, sys.stdin.readline().rstrip('\n').split(' ')))
	y2 = list(map(int, sys.stdin.readline().rstrip('\n').split(' ')))
	ans = 0
	corner_points = [(x1[1], 0), (x1[-1], 0), (x2[1], h), (x2[-1], h), (0, y1[1]), (0, y1[-1]), (w, y2[1]), (w, y2[-1])]
	for i in permutations(range(4), 2):
		p1 = corner_points[i[0] * 2]
		p2 = corner_points[i[0] * 2 + 1]
		p3 = corner_points[i[1] * 2]
		area = abs(p1[0] * p2[1] + p2[0] * p3[1] + p3[0] * p1[1] - p2[0] * p1[1] - p3[0] * p2[1] - p1[0] * p3[1])
		ans = max(ans, area)
	print(ans)


for t in range(int(input())):
	(w, h) = map(int, input().split())
	v1 = list(map(int, input().split()))
	v2 = list(map(int, input().split()))
	h1 = list(map(int, input().split()))
	h2 = list(map(int, input().split()))
	values = [(v1[-1] - v1[1]) * h, (v2[-1] - v2[1]) * h, (h1[-1] - h1[1]) * w, (h2[-1] - h2[1]) * w]
	print(max(values))


t = int(input())

def solve(h, arr, brr):
	b = 0
	arr.sort()
	brr.sort()
	if len(arr) > 1:
		b = arr[len(arr) - 1] - arr[0]
	if len(brr) > 1:
		b = max(b, brr[len(brr) - 1] - brr[0])
	return b * h
while t > 0:
	t -= 1
	(w, h) = [int(x) for x in input().split(' ')]
	arr = [int(x) for x in input().split(' ')]
	brr = [int(x) for x in input().split(' ')]
	arr1 = [int(x) for x in input().split(' ')]
	brr1 = [int(x) for x in input().split(' ')]
	print(max(solve(h, list(arr[1:]), list(brr[1:])), solve(w, list(arr1[1:]), list(brr1[1:]))))


t = int(input())
z = 1
while z <= t:
	n = input().split()
	w = int(n[0])
	h = int(n[1])
	b = 1
	f = []
	while b <= 4:
		if b == 1 or b == 2:
			p = input().split()
			c = int(p[0])
			d = int(p[c]) - int(p[1])
			e = d * h
			f.append(e)
			b = b + 1
		elif b == 3 or b == 4:
			p = input().split()
			c = int(p[0])
			d = int(p[c]) - int(p[1])
			e = d * w
			f.append(e)
			b = b + 1
	print(max(f))
	z = z + 1


import sys
cases = int(sys.stdin.readline())
for i in range(cases):
	(w, h) = map(int, sys.stdin.readline().split())
	x_1 = list(map(int, sys.stdin.readline().split()))
	x_2 = list(map(int, sys.stdin.readline().split()))
	x = max((x_1[-1] - x_1[1]) * h, (x_2[-1] - x_2[1]) * h)
	y_1 = list(map(int, sys.stdin.readline().split()))
	y_2 = list(map(int, sys.stdin.readline().split()))
	y = max((y_1[-1] - y_1[1]) * w, (y_2[-1] - y_2[1]) * w)
	print(max(x, y))


t = int(input())
str_sets = []
for _ in range(t):
	a = [input() for _ in range(5)]
	str_sets.append(a)

def bigest_w(str_set):
	(_, a, *_, b) = str_set.split()
	return int(b) - int(a)
for str_set in str_sets:
	(h, w) = map(int, str_set[0].split())
	each_w = (bigest_w(x) for x in str_set[1:])
	areas = (s * l for (s, l) in zip([w, w, h, h], each_w))
	print(max(areas))


import sys
from bisect import bisect_left as lb
from bisect import bisect_right as rb
from collections import deque
from queue import PriorityQueue as pq
from math import gcd
input_ = lambda : sys.stdin.readline().strip('\r\n')
ii = lambda : int(input_())
il = lambda : list(map(int, input_().split()))
ilf = lambda : list(map(float, input_().split()))
lii = lambda : list(map(int, list(ip())))
ip = lambda : input_()
fi = lambda : float(input_())
ap = lambda ab, bc, cd: ab[bc].append(cd)
li = lambda : list(input_())
pr = lambda x: print(x)
prinT = lambda x: print(x)
f = lambda : sys.stdout.flush()
inv = lambda x: pow(x, mod - 2, mod)
dx = [0, 0, 1, -1]
dy = [1, -1, 0, 0]
mod = 10 ** 9 + 7
mod1 = 998244353
for _ in range(ii()):
	(w, h) = il()
	a = []
	ans = 0
	for i in range(2):
		x = il()
		mn = min(x[1:])
		mx = max(x[1:])
		ans = max(ans, (mx - mn) * h)
	for i in range(2):
		x = il()
		mn = min(x[1:])
		mx = max(x[1:])
		ans = max(ans, (mx - mn) * w)
	print(ans)


import os, sys
from io import BytesIO, IOBase
from types import GeneratorType
from bisect import *
from collections import defaultdict, deque, Counter
import math, string
from heapq import *
from operator import add
from itertools import accumulate
BUFSIZE = 8192
sys.setrecursionlimit(10 ** 5)

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
inf = float('inf')
en = lambda x: list(enumerate(x))
ceil_ = lambda a, b: (a + b - 1) // b
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())

def solve():
	(a, b) = r()
	arr = [rr()[1:] for _ in ' ' * 2]
	brr = [rr()[1:] for _ in ' ' * 2]
	ans = -inf
	for j in arr:
		x = (max(j) - min(j)) * b
		ans = max(ans, x)
	for j in brr:
		x = (max(j) - min(j)) * a
		ans = max(ans, x)
	print(ans)
for _ in ' ' * ii():
	solve()


def findmax(a):
	return abs(a[len(a) - 1] - a[1])
t = int(input())
for _ in range(t):
	(w, h) = map(int, input().split())
	w1 = list(map(int, input().split()))
	w2 = list(map(int, input().split()))
	h1 = list(map(int, input().split()))
	h2 = list(map(int, input().split()))
	maxx = max(findmax(w1) * h, findmax(w2) * h, findmax(h1) * w, findmax(h2) * w)
	print(maxx)


from sys import stdin, stdout, setrecursionlimit
from io import BytesIO, IOBase
from math import gcd, floor, sqrt, ceil
setrecursionlimit(10000)

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None
		self.BUFSIZE = 8192

	def read(self):
		while True:
			a = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, self.BUFSIZE))
			if not a:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(a), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			a = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, self.BUFSIZE))
			self.newlines = a.count(b'\n') + (not a)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(a), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(stdin, stdout) = (IOWrapper(stdin), IOWrapper(stdout))
input = lambda : stdin.readline().rstrip('\r\n')
inp = lambda : int(input())
st = lambda : input().strip()
jn = lambda x, l: x.join(map(str, l))
int_arr = lambda : list(map(int, input().strip().split()))
str_arr = lambda : list(map(str, input().split()))
get_str = lambda : map(str, input().strip().split())
get_int = lambda : map(int, input().strip().split())
get_float = lambda : map(float, input().strip().split())
mod = 1000000007

def area(b1, b2, h):
	return abs(b2 - b1) * h
for _ in range(inp()):
	(w, h) = get_int()
	(x1, x2, y1, y2) = ([], [], [], [])
	for i in range(4):
		arr = int_arr()[1:]
		if i == 0:
			x1 += arr
		elif i == 1:
			x2 += arr
		elif i == 2:
			y1 += arr
		else:
			y2 += arr
	mx = max(area(x1[0], x1[-1], h), area(x2[0], x2[-1], h), area(y1[0], y1[-1], w), area(y2[0], y2[-1], w))
	print(mx)


n = int(input())
for i in range(n):
	(w, h) = map(int, input().split())
	xyn = list(map(int, input().split()))[1:]
	xym = list(map(int, input().split()))[1:]
	xny = list(map(int, input().split()))[1:]
	xmy = list(map(int, input().split()))[1:]
	xynm = max(xyn) - min(xyn)
	xymm = max(xym) - min(xym)
	xnym = max(xny) - min(xny)
	xmym = max(xmy) - min(xmy)
	if max(xynm, xymm) * h > max(xnym, xmym) * w:
		print(max(xynm, xymm) * h)
	else:
		print(max(xnym, xmym) * w)


t = int(input())
for _ in range(t):
	(w, h) = map(int, input().split())
	f = 0
	for i in range(4):
		a = input().split()
		for j in range(len(a)):
			a[j] = int(a[j])
		k = a[1:]
		if i <= 1:
			f = max(f, (k[len(k) - 1] - k[0]) * h)
		else:
			f = max(f, (k[len(k) - 1] - k[0]) * w)
	print(f)


import os
import sys
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heapify, heappop, heappush, nlargest, nsmallest
from io import BytesIO, IOBase
from math import inf, sqrt
from types import GeneratorType
BUFSIZE: int = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc

def modInverse(a, m):
	g = gcd(a, m)
	if g != 1:
		return -1
	else:
		return power(a, m - 2, m)

def power(x, y, m):
	if y == 0:
		return 1
	p = power(x, y // 2, m) % m
	p = p * p % m
	if y % 2 == 0:
		return p
	else:
		return x * p % m

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	ans = set()
	for p in range(2, n + 1):
		if prime[p]:
			ans.add(p)
	return ans
MOD = 1000000007
INT_MAX = inf
INT_MIN = -inf

def main():
	t = int(input())
	for _ in range(t):
		temp = list(map(int, input().split()))
		(w, h) = (temp[0], temp[1])
		hp1 = list(map(int, input().split()))
		hp2 = list(map(int, input().split()))
		vp1 = list(map(int, input().split()))
		vp2 = list(map(int, input().split()))
		hp1.pop(0)
		hp2.pop(0)
		vp1.pop(0)
		vp2.pop(0)
		ans = -1
		ans = max((hp1[-1] - hp1[0]) * h, ans)
		ans = max((hp2[-1] - hp2[0]) * h, ans)
		ans = max((vp1[-1] - vp1[0]) * w, ans)
		ans = max((vp2[-1] - vp2[0]) * w, ans)
		print(ans)
main()


for _ in range(int(input())):
	(w, h) = map(int, input().split())
	h1 = list(map(int, input().split()))
	h2 = list(map(int, input().split()))
	v1 = list(map(int, input().split()))
	v2 = list(map(int, input().split()))
	a1 = h1[-1] - h1[1]
	a2 = h2[-1] - h2[1]
	a3 = v1[-1] - v1[1]
	a4 = v2[-1] - v2[1]
	l1 = max(a1, a2) * h
	l2 = max(a3, a4) * w
	print(max(l1, l2))


for _ in range(int(input())):
	(w, h) = map(int, input().split())
	w1 = list(map(int, input().split()))
	w1 = w1[1:]
	w2 = list(map(int, input().split()))
	w2 = w2[1:]
	h1 = list(map(int, input().split()))
	h1 = h1[1:]
	h2 = list(map(int, input().split()))
	h2 = h2[1:]
	area = h * (max(w1) - min(w1))
	area1 = h * (max(w2) - min(w2))
	area2 = w * (max(h1) - min(h1))
	area3 = w * (max(h2) - min(h2))
	print(max(area, area1, area2, area3))


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	res = max(max(a[-1] - a[1], b[-1] - b[1]) * y, max(c[-1] - c[1], d[-1] - d[1]) * x)
	print(res)


def area(x1, y1, x2, y2, x3, y3):
	return abs(x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2))
for _ in range(int(input())):
	(n, m) = [int(a) for a in input().split()]
	X = list(map(int, input().split()))
	b = []
	for i in X:
		b.append([i, 0])
	X = b
	XX = list(map(int, input().split()))
	b = []
	for i in XX:
		b.append([i, m])
	XX = b
	Y = list(map(int, input().split()))
	b = []
	for i in Y:
		b.append([0, i])
	Y = b
	YY = list(map(int, input().split()))
	b = []
	for i in YY:
		b.append([n, i])
	YY = b
	ar = []
	for i in XX:
		k = area(X[-1][0], X[-1][1], X[1][0], X[1][1], i[0], i[1])
		ar.append(k)
	for i in X:
		k = area(XX[-1][0], XX[-1][1], XX[1][0], XX[1][1], i[0], i[1])
		ar.append(k)
	for i in YY:
		k = area(Y[-1][0], Y[-1][1], Y[1][0], Y[1][1], i[0], i[1])
		ar.append(k)
	for i in Y:
		k = area(YY[-1][0], YY[-1][1], YY[1][0], YY[1][1], i[0], i[1])
		ar.append(k)
	print(max(ar))


for _ in range(int(input())):
	(w, h) = map(int, input().strip().split())
	(_, *xbs) = map(int, input().strip().split())
	(_, *xus) = map(int, input().strip().split())
	(_, *yls) = map(int, input().strip().split())
	(_, *yrs) = map(int, input().strip().split())
	ars = [abs(xbs[0] - xbs[-1]) * h, abs(xus[0] - xus[-1]) * h, abs(yls[0] - yls[-1]) * w, abs(yrs[0] - yrs[-1]) * w]
	print(max(ars))


T = int(input())
for i in range(T):
	(w, h) = map(int, input().split())
	x1 = list(map(int, input().split()))
	x2 = list(map(int, input().split()))
	y1 = list(map(int, input().split()))
	y2 = list(map(int, input().split()))
	area = 0
	for i in range(y1[0]):
		area = max(y1[i + 1] * (x1[-1] - x1[1]), area)
		area = max((h - y1[i + 1]) * (x2[-1] - x2[1]), area)
	for j in range(x2[0]):
		area = max(h * (x1[-1] - x1[1]), area)
	for j in range(x1[0]):
		area = max(h * (x2[-1] - x2[1]), area)
	for j in range(y1[0]):
		area = max(w * (y2[-1] - y2[1]), area)
	for j in range(y2[0]):
		area = max(w * (y1[-1] - y1[1]), area)
	for i in range(y2[0]):
		area = max(y2[i + 1] * (x1[-1] - x1[1]), area)
		area = max((h - y2[i + 1]) * (x2[-1] - x2[1]), area)
	for j in range(x1[0]):
		area = max(x1[j + 1] * (y1[-1] - y1[1]), area)
		area = max((w - x1[j + 1]) * (y2[-1] - y2[1]), area)
	for j in range(x2[0]):
		area = max(x2[j + 1] * (y1[-1] - y1[1]), area)
		area = max((w - x2[j + 1]) * (y2[-1] - y2[1]), area)
	print(area)


import sys
import os.path
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
	sys.stderr = open('error.txt', 'w')
depth = 200001
mod = 1000000007
lim = mod * mod
sys.setrecursionlimit(depth)
linp = lambda : list(minp())
minp = lambda : map(int, input().split())
from math import inf, ceil, sqrt, log2, gcd
from collections import defaultdict, deque
dxy = [(1, 0), (-1, 0), (0, 1), (0, -1)]

def expo(a, b):
	if not b:
		return 1
	v = expo(a, b // 2)
	v = v * v % mod
	if b % 2:
		v = v * a % mod
	return v

def modinv(a, b):
	d = expo(b, mod - 2)
	v = a * d % mod
	return v

def checkPrime(n):
	if n < 4:
		return True
	if n % 2 == 0:
		return False
	for i in range(3, int(sqrt(n)) + 1, 2):
		if n % i == 0:
			return False
	return True

def highestPowerof2(x):
	x |= x >> 1
	x |= x >> 2
	x |= x >> 4
	x |= x >> 8
	x |= x >> 16
	return x ^ x >> 1
for _ in range(int(input())):
	(w, h) = map(int, input().split())
	(a, b, c, d) = (linp(), linp(), linp(), linp())
	ans1 = h * max(a[-1] - a[1], b[-1] - b[1])
	ans2 = w * max(c[-1] - c[1], d[-1] - d[1])
	print(max(ans1, ans2))


for t in range(int(input())):
	(w, h) = map(int, input().split(' '))
	m = -1
	for i in range(4):
		a = list(map(int, input().split(' ')))[1:]
		if i < 2:
			m = max(m, (max(a) - min(a)) * h)
		else:
			m = max(m, (max(a) - min(a)) * w)
	print(m)


R = lambda : map(int, input().split())
(t,) = R()
while t:
	t -= 1
	(w, h) = R()
	r = 0
	for x in [h, h, w, w]:
		(k, m, *_, M) = R()
		r = max(r, x * (M - m))
	print(r)


for _ in range(int(input())):
	(m, n) = map(int, input().split())
	res = 0
	for i in range(4):
		a = [int(x) for x in input().split()][1:]
		res = max(res, (a[-1] - a[0]) * (n if i < 2 else m))
	print(res)


n = int(input())
while n:
	n -= 1
	(w, h) = list(map(int, input().split()))
	y0 = list(map(int, input().split()))
	y00 = (y0[-1] - y0[1]) * h
	yh = list(map(int, input().split()))
	yhh = (yh[-1] - yh[1]) * h
	x0 = list(map(int, input().split()))
	x00 = (x0[-1] - x0[1]) * w
	xw = list(map(int, input().split()))
	xww = (xw[-1] - xw[1]) * w
	m = max(y00, yhh, x00, xww)
	print(m)


n = int(input())
killer = []
for i in range(n):
	mylist1 = list(map(int, input().split()))
	mylist2 = list(map(int, input().split()))
	mylist3 = list(map(int, input().split()))
	mylist4 = list(map(int, input().split()))
	mylist5 = list(map(int, input().split()))
	mylist2.pop(0)
	mylist3.pop(0)
	mylist4.pop(0)
	mylist5.pop(0)
	area1 = (max(mylist2) - min(mylist2)) * mylist1[1]
	area2 = (max(mylist3) - min(mylist3)) * mylist1[1]
	area3 = (max(mylist4) - min(mylist4)) * mylist1[0]
	area4 = (max(mylist5) - min(mylist5)) * mylist1[0]
	killer.append(max(area1, area2, area3, area4))
print(*killer, sep='\n')


def larger(a, b):
	if a >= b:
		return a
	else:
		return b

def hori_can(h1, h2, h):
	can1 = h1[h1[0]] - h1[1]
	can2 = h2[h2[0]] - h2[1]
	return larger(can1, can2) * h

def vert_can(v1, v2, w):
	can1 = v1[v1[0]] - v1[1]
	can2 = v2[v2[0]] - v2[1]
	return larger(can1, can2) * w
test_cases = int(input())
for i in range(test_cases):
	dim = input()
	dim = dim.split()
	dim = [int(i) for i in dim]
	h1 = input()
	h1 = h1.split()
	h1 = [int(i) for i in h1]
	h2 = input()
	h2 = h2.split()
	h2 = [int(i) for i in h2]
	v1 = input()
	v1 = v1.split()
	v1 = [int(i) for i in v1]
	v2 = input()
	v2 = v2.split()
	v2 = [int(i) for i in v2]
	print(larger(hori_can(h1, h2, dim[1]), vert_can(v1, v2, dim[0])))


import math
import collections

def modInverse(p, q):
	mod = 998244353
	expo = 0
	expo = mod - 2
	while expo:
		if expo & 1:
			p = p * q % mod
		q = q * q % mod
		expo >>= 1
	return p

def answer(x, y, li):
	s = []
	for p in range(0, len(li) - 1):
		s.append(li[p + 1] - li[p])
	s.append(int(1e+18))

	def solu(s, fi, y):
		m = 0
		for j in range(0, len(s)):
			m = m + min(s[j], fi)
		return m >= y
	low = 1
	high = int(1e+18)
	ans = 0
	while low < high:
		fi = (low + high) // 2
		if solu(s, fi, y):
			high = fi
			ans = fi
		else:
			low = fi + 1
	return ans
t = int(input())
for i in range(0, t):
	(x, y) = input().split()
	x = int(x)
	y = int(y)
	x1 = input().split()
	x2 = input().split()
	y1 = input().split()
	y2 = input().split()
	if (int(x1[-1]) - int(x1[1])) * y > (int(x2[-1]) - int(x2[1])) * y:
		ans1 = (int(x1[-1]) - int(x1[1])) * y
	else:
		ans1 = (int(x2[-1]) - int(x2[1])) * y
	if (int(y1[-1]) - int(y1[1])) * x > (int(y2[-1]) - int(y2[1])) * x:
		ans2 = (int(y1[-1]) - int(y1[1])) * x
	else:
		ans2 = (int(y2[-1]) - int(y2[1])) * x
	if ans1 > ans2:
		print(ans1)
	else:
		print(ans2)


t = int(input())
for i in range(0, t):
	(w, h) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	h1 = abs(a[-1] - a[1])
	h2 = abs(b[-1] - b[1])
	v1 = abs(c[-1] - c[1])
	v2 = abs(d[-1] - d[1])
	a1 = h1 * h
	a2 = h2 * h
	a3 = v1 * w
	a4 = v2 * w
	print(max(a1, a2, a3, a4))


t = int(input())
while t != 0:
	(w, h) = [int(x) for x in input().split()]
	x1 = [int(x) for x in input().split()]
	x2 = [int(x) for x in input().split()]
	y1 = [int(x) for x in input().split()]
	y2 = [int(x) for x in input().split()]
	x1 = x1[1:]
	x2 = x2[1:]
	y1 = y1[1:]
	y2 = y2[1:]
	x1.sort()
	x2.sort()
	y1.sort()
	y2.sort()
	x1max = x1[-1] - x1[0]
	x2max = x2[-1] - x2[0]
	y1max = y1[-1] - y1[0]
	y2max = y2[-1] - y2[0]
	maxmax = max([x1max * h, x2max * h, y1max * w, y2max * w])
	print(maxmax)
	t -= 1


test = int(input())
for i in range(test):
	(w, h) = list(map(int, input().split()))
	botList = list(map(int, input().split()))
	botPoints = botList[0]
	botList = botList[1:]
	baseBot = max(botList) - min(botList)
	topList = list(map(int, input().split()))
	topPoints = topList[0]
	topList = topList[1:]
	baseTop = max(topList) - min(topList)
	leftList = list(map(int, input().split()))
	leftPoints = leftList[0]
	leftList = leftList[1:]
	baseLeft = max(leftList) - min(leftList)
	rightList = list(map(int, input().split()))
	rightPoints = rightList[0]
	rightList = rightList[1:]
	baseRight = max(rightList) - min(rightList)
	print(max(baseBot * h, baseTop * h, baseLeft * w, baseRight * w))


def solve():
	(w, h) = map(int, input().split())
	hoanh_duoi = list(input().split())
	hoanh_tren = list(input().split())
	tung_trai = list(input().split())
	tung_phai = list(input().split())
	max_hoanh = max(int(int(hoanh_duoi[-1]) - int(hoanh_duoi[1])), int(hoanh_tren[-1]) - int(hoanh_tren[1]))
	max_tung = max(int(int(tung_trai[-1]) - int(tung_trai[1])), int(tung_phai[-1]) - int(tung_phai[1]))
	print(max(max_hoanh * h, max_tung * w))
for i in range(int(input())):
	solve()


import sys
input = lambda : sys.stdin.readline().rstrip()
INF = 10 ** 19

def solve():
	(w, h) = map(int, input().split())
	x1 = list(map(int, input().split()))[1:]
	x2 = list(map(int, input().split()))[1:]
	y1 = list(map(int, input().split()))[1:]
	y2 = list(map(int, input().split()))[1:]
	ans = 0
	if len(x1) >= 2:
		ans = max(ans, (x1[-1] - x1[0]) * h)
	if len(x2) >= 2:
		ans = max(ans, (x2[-1] - x2[0]) * h)
	if len(y1) >= 2:
		ans = max(ans, (y1[-1] - y1[0]) * w)
	if len(y2) >= 2:
		ans = max(ans, (y2[-1] - y2[0]) * w)
	print(ans)
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	(w, h) = map(int, input().split())
	w1 = list(map(int, input().split()))
	w2 = list(map(int, input().split()))
	h1 = list(map(int, input().split()))
	h2 = list(map(int, input().split()))
	w1.pop(0)
	w2.pop(0)
	h1.pop(0)
	h2.pop(0)
	ans = [(max(w1) - min(w1)) * h, (max(w2) - min(w2)) * h, (max(h1) - min(h1)) * w, (max(h2) - min(h2)) * w]
	print(max(ans))


for _ in range(int(input())):
	(w, h) = map(int, input().split())
	xa = list(map(int, input().split()))
	xb = list(map(int, input().split()))
	ya = list(map(int, input().split()))
	yb = list(map(int, input().split()))
	choices = [(xa[-1] - xa[1]) * h, (xb[-1] - xb[1]) * h, (ya[-1] - ya[1]) * w, (yb[-1] - yb[1]) * w]
	res = max(choices)
	print(res)


t = int(input())
for _ in range(t):
	(w, h) = list(map(int, input().split()))
	x1 = list(map(int, input().split()))[1:]
	x2 = list(map(int, input().split()))[1:]
	y1 = list(map(int, input().split()))[1:]
	y2 = list(map(int, input().split()))[1:]
	z1 = max(x1) - min(x1)
	z2 = max(x2) - min(x2)
	z3 = max(y1) - min(y1)
	z4 = max(y2) - min(y2)
	z = max(z1, z2)
	zz = max(z3, z4)
	j = max(z * h, zz * w)
	print(j)


t = int(input())
for i in range(t):
	(w, h) = input().split()
	(w, h) = (int(w), int(h))
	max_res = 0
	x1 = input().split()
	x2 = input().split()
	y1 = input().split()
	y2 = input().split()
	base1 = int(x1[len(x1) - 1]) - int(x1[1])
	base2 = int(x2[len(x2) - 1]) - int(x2[1])
	height1 = int(y1[len(y1) - 1]) - int(y1[1])
	height2 = int(y2[len(y2) - 1]) - int(y2[1])
	print(max(h * max(base1, base2), w * max(height1, height2)))


def maxd():
	L = list(map(int, input().split()))
	return L[-1] - L[1]
for _ in range(int(input())):
	(w, h) = map(int, input().split())
	al = [maxd() * h, maxd() * h, maxd() * w, maxd() * w]
	print(max(al))


import sys
input = sys.stdin.readline

def solve():
	(w, h) = map(int, input().split())
	x1 = list(map(int, input().split()))
	x2 = list(map(int, input().split()))
	y1 = list(map(int, input().split()))
	y2 = list(map(int, input().split()))
	(a, b, c, d) = (x1[-1] - x1[1], x2[-1] - x2[1], y1[-1] - y1[1], y2[-1] - y2[1])
	return max(a * h, b * h, c * w, d * w)
for _ in range(int(input())):
	print(solve())


from collections import Counter
from sys import *
from collections import defaultdict as dd
from math import *

def inp():
	return int(stdin.readline().strip())

def vinp():
	return map(int, stdin.readline().strip().split())

def linp():
	return list(map(int, stdin.readline().strip().split()))

def sinp(n=1):
	if n == 1:
		return stdin.readline().strip()
	elif n == 2:
		return list(stdin.readline().strip())
	else:
		return list(stdin.readline().split())

def pr(*x, end='\n'):
	print(*x, end=end)

def mod(f, val=1000000007):
	return f % val

def csort(c):
	sorted(c.items(), key=lambda pair: pair[1], reverse=True)

def indc(l, n):
	c = {}
	for i in range(n):
		c[l[i]] = c.get(l[i], []) + [i + 1]
	return c
cou = inp()
for _ in range(cou):
	(w, h) = vinp()
	l1 = linp()[1:]
	l2 = linp()[1:]
	l3 = linp()[1:]
	l4 = linp()[1:]
	ma1 = max(l1)
	ma2 = max(l2)
	ma3 = max(l3)
	ma4 = max(l4)
	mi1 = min(l1)
	mi2 = min(l2)
	mi3 = min(l3)
	mi4 = min(l4)
	l = [abs(ma1 - mi1) * h, abs(ma2 - mi2) * h, abs(ma3 - mi3) * w, abs(ma4 - mi4) * w]
	pr(max(l))


from collections import defaultdict
from math import gcd
from os import path, truncate
from sys import int_info, stdin, stdout
if path.exists('tc.txt'):
	stdin = open('tc.txt', 'r')

def gmi():
	return map(int, stdin.readline().strip().split())

def gms():
	return map(str, stdin.readline().strip().split())

def gari():
	return list(map(int, stdin.readline().strip().split()))

def gart():
	return tuple(map(int, stdin.readline().strip().split()))

def gars():
	return list(map(str, stdin.readline().strip().split()))

def gs():
	return stdin.readline().strip()

def gls():
	return list(stdin.readline().strip())

def gi():
	return int(stdin.readline())
for _ in range(gi()):
	(w, h) = map(int, input().split())
	xw = list(map(int, input().split()))
	xwh = list(map(int, input().split()))
	yh = list(map(int, input().split()))
	yhw = list(map(int, input().split()))
	a = (xw[-1] - xw[1]) * h
	b = (xwh[-1] - xwh[1]) * h
	c = (yh[-1] - yh[1]) * w
	d = (yhw[-1] - yhw[1]) * w
	ab = max(a, b)
	cd = max(c, d)
	print(max(ab, cd))


cases = int(input())
for _ in range(cases):
	(w, h) = map(int, input().split())
	points_down = list(map(int, input().split()))[1:]
	points_up = list(map(int, input().split()))[1:]
	points_left = list(map(int, input().split()))[1:]
	points_right = list(map(int, input().split()))[1:]
	max_dist = 0
	dist_down = points_down[-1] - points_down[0]
	tri_down = dist_down * h
	max_dist = max(tri_down, max_dist)
	dist_up = points_up[-1] - points_up[0]
	tri_up = dist_up * h
	max_dist = max(tri_up, max_dist)
	dist_left = points_left[-1] - points_left[0]
	tri_left = dist_left * w
	max_dist = max(tri_left, max_dist)
	dist_right = points_right[-1] - points_right[0]
	tri_right = dist_right * w
	max_dist = max(tri_right, max_dist)
	print(max_dist)


testcases = int(input())
for _ in range(testcases):
	coordinates = input().split()
	w = int(coordinates[0])
	h = int(coordinates[1])
	trianglesizes = []
	for _ in range(2):
		points_all = input().split()
		amount_points = int(points_all[0])
		trianglesizes.append((int(points_all[amount_points]) - int(points_all[1])) * h)
	for _ in range(2):
		points_all = input().split()
		amount_points = int(points_all[0])
		trianglesizes.append((int(points_all[amount_points]) - int(points_all[1])) * w)
	print(max(trianglesizes))


import sys
IN = sys.stdin
OUT = sys.stdout
tc = int(IN.readline())
for ti in range(tc):
	(w, h) = map(int, IN.readline().strip().split())
	a1 = tuple(map(int, IN.readline().strip().split()))
	a2 = tuple(map(int, IN.readline().strip().split()))
	a3 = tuple(map(int, IN.readline().strip().split()))
	a4 = tuple(map(int, IN.readline().strip().split()))
	ans = 0
	c = (a1[-1] - a1[1]) * h
	if ans < c:
		ans = c
	c = (a2[-1] - a2[1]) * h
	if ans < c:
		ans = c
	c = (a3[-1] - a3[1]) * w
	if ans < c:
		ans = c
	c = (a4[-1] - a4[1]) * w
	if ans < c:
		ans = c
	print(ans)


ans = []
for _ in range(int(input())):
	(w, h) = map(int, input().split())
	hor1 = list(map(int, input().split()))
	hor2 = list(map(int, input().split()))
	ver1 = list(map(int, input().split()))
	ver2 = list(map(int, input().split()))
	ans.append(max(w * max(ver1[-1] - ver1[1], ver2[-1] - ver2[1]), h * max(hor1[-1] - hor1[1], hor2[-1] - hor2[1])))
print(*ans, sep='\n')


import sys
input = sys.stdin.readline
M = 1000000007

def solve():
	(w, h) = map(int, input().split())
	(_, *br) = list(map(int, input().split()))
	br.sort()
	(_, *tr) = list(map(int, input().split()))
	tr.sort()
	(_, *rc) = list(map(int, input().split()))
	rc.sort()
	(_, *lc) = list(map(int, input().split()))
	lc.sort()
	return max(max(br[-1] - br[0], tr[-1] - tr[0]) * h, max(rc[-1] - rc[0], lc[-1] - lc[0]) * w)
for _ in range(int(input())):
	print(solve())


t = int(input())
for _ in range(t):
	(w, h) = map(int, input().split())
	O_hor = list(map(int, input().split()))
	h_hor = list(map(int, input().split()))
	O_ver = list(map(int, input().split()))
	h_ver = list(map(int, input().split()))
	a1 = (O_hor[-1] - O_hor[1]) * h
	a2 = (h_hor[-1] - h_hor[1]) * h
	a3 = (O_ver[-1] - O_ver[1]) * w
	a4 = (h_ver[-1] - h_ver[1]) * w
	print(max(a1, a2, a3, a4))


t = int(input())
dim = []
x_0 = []
x_h = []
y_0 = []
y_w = []
for i in range(t):
	dim.append(list(map(int, input().split())))
	x_0.append([int(x) for x in input().split()])
	x_h.append([int(x) for x in input().split()])
	y_0.append([int(x) for x in input().split()])
	y_w.append([int(x) for x in input().split()])
for i in range(t):
	x_0[i].pop(0)
	x_h[i].pop(0)
	y_0[i].pop(0)
	y_w[i].pop(0)
	w = dim[i][0]
	h = dim[i][1]
	x_0a = (max(x_0[i]) - min(x_0[i])) * h
	x_ha = (max(x_h[i]) - min(x_h[i])) * h
	y_0a = (max(y_0[i]) - min(y_0[i])) * w
	y_wa = (max(y_w[i]) - min(y_w[i])) * w
	ans = max([x_0a, x_ha, y_0a, y_wa])
	print(ans)


testNum = int(input())
i = 0
ansArray = []
while i < testNum:
	incord = input().split()
	cord = list(map(int, incord))
	x_1 = list(map(int, input().split()))
	x_2 = list(map(int, input().split()))
	y_1 = list(map(int, input().split()))
	y_2 = list(map(int, input().split()))
	a = (x_1[x_1[0]] - x_1[1]) * cord[1]
	b = (x_2[x_2[0]] - x_2[1]) * cord[1]
	c = (y_1[y_1[0]] - y_1[1]) * cord[0]
	d = (y_2[y_2[0]] - y_2[1]) * cord[0]
	ansArray.append(max(a, b, c, d))
	i += 1
for x in ansArray:
	print(x)


for _ in range(int(input())):
	(w, h) = map(int, input().split())
	x1 = list(map(int, input().split()))
	x2 = list(map(int, input().split()))
	y1 = list(map(int, input().split()))
	y2 = list(map(int, input().split()))
	x = x1[1:]
	x3 = x2[1:]
	y = y1[1:]
	y3 = y2[1:]
	r1 = (max(x) - min(x)) * h
	r2 = (max(x3) - min(x3)) * h
	r3 = (max(y) - min(y)) * w
	r4 = (max(y3) - min(y3)) * w
	print(max(r1, r2, r3, r4))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(w, h) = map(int, input().split())
	val = []
	for i in range(4):
		ar1 = list(map(int, input().split()))
		v1 = abs(ar1[-1] - ar1[1])
		val.append(v1)
	ans = 0
	ans = max(ans, val[0] * h)
	ans = max(ans, val[1] * h)
	ans = max(ans, val[2] * w)
	ans = max(ans, val[3] * w)
	print(ans)