Nian is a monster which lives deep in the oceans. Once a year, it shows up on the land, devouring livestock and even people. In order to keep the monster away, people fill their villages with red colour, light, and cracking noise, all of which frighten the monster out of coming.

Little Tommy has n lanterns and Big Banban has m lanterns. Tommy's lanterns have brightness a_1, a_2, ..., a_{n}, and Banban's have brightness b_1, b_2, ..., b_{m} respectively.

Tommy intends to hide one of his lanterns, then Banban picks one of Tommy's non-hidden lanterns and one of his own lanterns to form a pair. The pair's brightness will be the product of the brightness of two lanterns.

Tommy wants to make the product as small as possible, while Banban tries to make it as large as possible.

You are asked to find the brightness of the chosen pair if both of them choose optimally.


-----Input-----

The first line contains two space-separated integers n and m (2 ≤ n, m ≤ 50).

The second line contains n space-separated integers a_1, a_2, ..., a_{n}.

The third line contains m space-separated integers b_1, b_2, ..., b_{m}.

All the integers range from  - 10^9 to 10^9.


-----Output-----

Print a single integer — the brightness of the chosen pair.


-----Examples-----
Input
2 2
20 18
2 14

Output
252

Input
5 3
-1 0 1 2 3
-1 0 1

Output
2



-----Note-----

In the first example, Tommy will hide 20 and Banban will choose 18 from Tommy and 14 from himself.

In the second example, Tommy will hide 3 and Banban will choose 2 from Tommy and 1 from himself.

Difficulty: MEDIUM

Solutions:
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
rec = [[] for i in range(n)]
INF = float('inf')
for i in range(n):
	for j in range(m):
		rec[i].append(a[i] * b[j])
	rec[i] = sorted(rec[i], reverse=True)
ma = [-INF] * n
ind = 0
for i in range(n):
	if ma < rec[i]:
		ma = rec[i]
		ind = i
mq = -INF
for i in range(n):
	if i == ind:
		continue
	mq = max(mq, max(rec[i]))
print(mq)


(n, m) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
s = []
for i in a:
	m = -10 ** 20
	for j in b:
		m = max(m, i * j)
	s.append(m)
s.sort()
print(s[-2])


(n, m) = map(int, input().split())
a1 = [int(x) for x in input().split()]
a2 = [int(x) for x in input().split()]
a1.sort()
a2.sort()
ans1 = -1e+18
ans2 = -1e+18
for i in range(len(a1) - 1):
	for j in a2:
		ans1 = max(ans1, a1[i] * j)
for i in range(1, len(a1)):
	for j in a2:
		ans2 = max(ans2, a1[i] * j)
print(int(min(ans1, ans2)))


inf = -10 ** 18
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort(reverse=True)
if len(a) > 3:
	Max = [(a[0] * max(b), a[0] * min(b), 0 if 0 in b else inf), (a[1] * max(b), a[1] * min(b), 0 if 0 in b else inf), (0 if 0 in a else inf, 0 if 0 in a else inf), (a[len(a) - 2] * max(b), a[len(a) - 2] * min(b), 0 if 0 in b else inf), (a[len(a) - 1] * max(b), a[len(a) - 1] * min(b), 0 if 0 in b else inf)]
	MAX = [max(Max[0]), max(Max[1]), max(Max[2]), max(Max[3]), max(Max[4])]
else:
	Max = [list((j * i for i in b)) for j in a]
	MAX = [max(i) for i in Max]
MAX.sort(reverse=True)
print(MAX[1])


(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
big = 10 ** 25
small = -10 ** 25
first = []
for x in a:
	s = small
	for y in b:
		_ = x * y
		if _ > s:
			s = _
	first.append(s)
ans = big
for i in range(len(a)):
	s = small
	for j in range(len(a)):
		if j != i:
			if first[j] > s:
				s = first[j]
	if s < ans:
		ans = s
print(ans)


(n, m) = [int(i) for i in input().split(' ')]
A = [int(i) for i in input().split(' ')]
B = [int(i) for i in input().split(' ')]
C = []
maxval = A[0] * B[0]
ind = 0
ct = 0
for i in range(n):
	for j in range(m):
		if A[i] * B[j] > maxval:
			maxval = A[i] * B[j]
			ind = i
res = A[0] * B[0]
if ind == 0:
	res = A[1] * B[0]
for i in range(n):
	for j in range(m):
		if i != ind:
			res = max(res, A[i] * B[j])
print(res)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort(key=abs)
b.sort(key=abs)
maxi = -abs(a[-1] * b[-1]) - 1
I = 0
J = 0
for i in a:
	for j in b:
		o = max(maxi, i * j)
		if o != maxi:
			maxi = o
			I = i
			J = j
a.remove(I)
maxi = -abs(a[-1] * b[-1])
for i in a:
	for j in b:
		maxi = max(maxi, i * j)
print(maxi)


(n, m) = [int(i) for i in input().split()]
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = []
A.sort()
B.sort()
if max(A[0] * B[-1], A[0] * B[0]) > max(A[-1] * B[-1], A[-1] * B[0]):
	A = A[1:]
else:
	A = A[:-1]
for i in A:
	for j in B:
		ans.append(i * j)
print(max(ans))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans1 = 10 ** 18
for i in range(n):
	c = a[:i] + a[i + 1:]
	ans2 = -10 ** 18
	for j in c:
		for k in b:
			ans2 = max(j * k, ans2)
	ans1 = min(ans2, ans1)
print(ans1)


import copy
n = input()
a = [int(x) for x in input().split(' ')]
b = [int(x) for x in input().split(' ')]
best = 10000000000000000000000
for i in a:
	ahide = a.copy()
	ahide.remove(i)
	cand = -10000000000000000000000
	for x in ahide:
		for y in b:
			if x * y > cand:
				cand = x * y
	if cand < best:
		best = cand
print(best)


(n, m) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans1 = float('inf')
for i in range(n):
	ans2 = -float('inf')
	for j in range(n):
		if j == i:
			continue
		for k in range(m):
			ans2 = max(ans2, A[j] * B[k])
	ans1 = min(ans1, ans2)
print(ans1)


(n, m) = map(int, input().split())
v1 = list(map(int, input().split()))
v2 = list(map(int, input().split()))
ans = []
for item in v1:
	temp = []
	for elt in v2:
		temp.append(item * elt)
	ans.append(max(temp))
ans.sort()
print(ans[-2])


from __future__ import division, print_function
MOD = 998244353
mod = 10 ** 9 + 7

def prepare_factorial():
	fact = [1]
	for i in range(1, 100005):
		fact.append(fact[-1] * i % mod)
	ifact = [0] * 100005
	ifact[100004] = pow(fact[100004], mod - 2, mod)
	for i in range(100004, 0, -1):
		ifact[i - 1] = i * ifact[i] % mod
	return (fact, ifact)
import sys
from bisect import bisect_left, bisect_right, insort
from math import floor, ceil, sqrt, degrees, atan, pi, log, sin, radians
from heapq import heappop, heapify, heappush
from collections import Counter, defaultdict, deque

def modinv(n, p):
	return pow(n, p - 2, p)

def ncr(n, r, fact, ifact):
	t = fact[n] * (ifact[r] * ifact[n - r]) % mod % mod
	return t

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

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

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

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(x, y):
	return x * y // GCD(x, y)

def get_xor(n):
	return [n, 1, n + 1, 0][n % 4]

def fast_expo(a, b):
	res = 1
	while b:
		if b & 1:
			res = res * a
			res %= MOD
			b -= 1
		else:
			a = a * a
			a %= MOD
			b >>= 1
	res %= MOD
	return res

def get_n(P):
	ans = (-1 + sqrt(1 + 8 * P)) // 2
	return ans

def solve():
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	ans = []
	for i in range(n):
		out = []
		for j in range(n):
			if i == j:
				continue
			for k in range(m):
				out.append(a[j] * b[k])
		ans.append(max(out))
	print(min(ans))
	return

def main():
	T = 1
	while T:
		solve()
		T -= 1
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			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')
main()


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
print(min([max([max([a[j] * k for k in b]) for j in range(n) if j != i]) for i in range(n)]))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
b.sort()
low = b[0]
high = b[-1]
ans = []
for i in range(n):
	best = -10000000000000000000001
	for j in range(n):
		if i != j:
			best = max([best, low * a[j], a[j] * high])
	ans.append(best)
print(min(ans))


(n, m) = map(int, input().split())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
ma = l1[0] * l2[0]
for i in range(len(l1)):
	for j in range(len(l2)):
		su = l1[i] * l2[j]
		if su >= ma:
			ma = su
			i1 = i
l3 = []
for i in range(len(l1)):
	if i == i1:
		continue
	for j in range(len(l2)):
		su = l1[i] * l2[j]
		l3.append(su)
print(max(l3))


(n, m) = input().split()
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans_g = 1 << 60
for i in range(len(a)):
	ans = 1 << 60
	ans = -ans
	for j in range(len(a)):
		if j != i:
			for k in range(len(b)):
				ans = max(ans, a[j] * b[k])
	ans_g = min(ans, ans_g)
print(ans_g)


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
b.sort()
max1 = max(a[0] * b[0], a[0] * b[-1])
max2 = max(a[-1] * b[-1], a[-1] * b[0])
if max1 > max2:
	a.pop(0)
else:
	a.pop()
max1 = max(a[0] * b[0], a[0] * b[-1])
max2 = max(a[-1] * b[-1], a[-1] * b[0])
print(max(max1, max2))


from copy import copy
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
(x, y) = (0, 0)
A = copy(a)
A.remove(max(a))
x = max([max(A) * max(b), min(A) * min(b), max(A) * min(b), min(A) * max(b)])
A = copy(a)
A.remove(min(a))
y = max([max(A) * max(b), min(A) * min(b), max(A) * min(b), min(A) * max(b)])
print(min(x, y))


def first(num):
	return num[0]
(n, m) = map(int, input().split())
num = list(map(int, input().split()))
lst = list(map(int, input().split()))
pr = []
for i in range(n):
	for j in range(m):
		pr.append([num[i] * lst[j], num[i], lst[j]])
pr.sort(key=first)
pr.reverse()
num.pop(num.index(pr[0][1]))
ans = -100000000000000000000000000000
for i in range(n - 1):
	for j in range(m):
		if num[i] * lst[j] > ans:
			ans = num[i] * lst[j]
print(ans)


def main():
	(n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	min_a = min(a)
	max_a = max(a)
	min_b = min(b)
	max_b = max(b)
	prod_with_min_a = max(min_a * min_b, min_a * max_b)
	prod_with_max_a = max(max_a * min_b, max_a * max_b)
	if prod_with_max_a > prod_with_min_a:
		a.remove(max_a)
		max_a = max(a)
	else:
		a.remove(min_a)
		min_a = min(a)
	print(max(min_a * min_b, min_a * max_b, max_a * min_b, max_a * max_b))
main()


import sys

def printf(format, *args):
	sys.stdout.write(format % args)
(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
ans = 10 ** 19
for i in range(n):
	act = -10 ** 19
	for j in range(m):
		for k in range(n):
			if k == i:
				continue
			act = max(act, a[k] * b[j])
	ans = min(ans, act)
print(ans)


(n, m) = map(int, input().split())
n_data = sorted(list(map(int, input().split())))
m_data = sorted(list(map(int, input().split())))
products = sorted([[n_data[i] * m_data[j], i] for i in range(n) for j in range(m)])
init = products[n * m - 1][1]
for i in range(n * m - 1, -1, -1):
	if products[i][1] != init:
		print(products[i][0])
		break


from operator import neg
(n, m) = map(int, input().split())
s1 = list(map(int, input().split()))
s2 = list(map(int, input().split()))
m = 0
tmp = -10 ** 18 - 1
for i in s1:
	for j in s2:
		if i * j > tmp:
			m = i
			tmp = i * j
s1.remove(m)
tmp = -10 ** 18 - 1
for i in s1:
	for j in s2:
		if i * j > tmp:
			m = i
			tmp = i * j
print(tmp)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
mn = 10 ** 18
for i in range(n):
	mx = -10 ** 18
	for j in range(n):
		if j == i:
			continue
		for k in range(m):
			mx = max(mx, a[j] * b[k])
	mn = min(mn, mx)
print(mn)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = list()
for i in a:
	c = -10 ** 50
	for j in b:
		c = max(c, i * j)
	d.append(c)
d.sort()
print(d[-2])


(n, m) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
d = {}
for i in a:
	if i not in d:
		d[i] = 0
	d[i] += 1
pair = []
for i in range(n):
	for j in range(m):
		pair.append([a[i], b[j]])
pair.sort(key=lambda x: x[0] * x[1])
i = -2
if d[pair[-1][0]] > 1:
	print(pair[-1][0] * pair[-1][1])
else:
	while pair[i][0] == pair[i + 1][0] and d[pair[i][0]] == 1:
		i -= 1
	print(pair[i][0] * pair[i][1])


(n, m) = [int(x) for x in input().split()]
ns = [int(x) for x in input().split()]
ms = [int(x) for x in input().split()]
maxi = -1000000000000000000
hide = None
for i in ns:
	for j in ms:
		if i * j > maxi:
			maxi = j * i
			hide = i
if hide in ns:
	ns.remove(hide)
maxi = -1000000000000000000
for i in ns:
	for j in ms:
		if i * j > maxi:
			maxi = j * i
print(maxi)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = float('inf')
for i in range(n):
	now = -float('inf')
	for j in range(n):
		if j != i:
			for k in range(m):
				now = max(now, a[j] * b[k])
	ans = min(ans, now)
print(ans)


from operator import itemgetter
a = input()
b = input().split(' ')
b = [int(i) for i in b]
c = input().split(' ')
c = [int(i) for i in c]
ans = []
for j in range(len(b)):
	for k in range(len(c)):
		ans.append([j, b[j] * c[k]])
ans = sorted(ans, key=itemgetter(1))
tmp = ans[-1][0]
ans = []
for j in range(len(b)):
	if j != tmp:
		for k in range(len(c)):
			ans.append(b[j] * c[k])
ans = sorted(ans)
print(ans[-1])


(n, m) = [int(x) for x in input().split()]
t = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
id = [max(t) * max(b), max(t) * min(b), min(t) * max(b), min(t) * min(b)]
if id.index(max(id)) > 1:
	t.remove(min(t))
else:
	t.remove(max(t))
print(max(max(t) * max(b), max(t) * min(b), min(t) * max(b), min(t) * min(b)))


from math import inf

def compability(lst1, lst2):
	lst3 = [-inf] * len(lst1)
	for i in range(len(lst1)):
		for j in range(len(lst2)):
			lst3[i] = max(lst3[i], lst1[i] * lst2[j])
	return sorted(lst3)[len(lst1) - 2]
(n, m) = [int(x) for x in input().split()]
a = [int(y) for y in input().split()]
b = [int(z) for z in input().split()]
print(compability(a, b))


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
m = 10 ** 19
for k in range(n):
	t = -10 ** 19
	for i in range(n):
		if i != k:
			if a[i] >= 0:
				t = max(max(b) * a[i], t)
			else:
				t = max(min(b) * a[i], t)
	m = min(t, m)
print(m)


(n, m) = [x for x in input().strip().split()]
N = [int(x) for x in input().strip().split()]
M = [int(x) for x in input().strip().split()]
lm = min(M)
ln = min(N)
hm = max(M)
hn = max(N)
maximum = max([ln * lm, ln * hm, lm * hn, hm * hn])
if maximum == ln * lm or maximum == ln * hm:
	N.remove(ln)
	ln = min(N)
else:
	N.remove(hn)
	hn = max(N)
print(max([ln * lm, ln * hm, lm * hn, hm * hn]))


from sys import stdin, stdout

def rint():
	return map(int, stdin.readline().split())
(n, m) = rint()
a = []
b = []
a = list(rint())
b = list(rint())
Max = -10 ** 1000
maxi = -1
for i in range(n):
	for j in range(m):
		if Max < a[i] * b[j]:
			Max = a[i] * b[j]
			maxi = i
Max = -10 ** 1000
for i in range(n):
	if i == maxi:
		continue
	for j in range(m):
		if Max < a[i] * b[j]:
			Max = a[i] * b[j]
print(Max)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans1 = 10 ** 18
for i in range(n):
	ans = -10 ** 18
	arr = a[:i] + a[i + 1:]
	for k in range(n - 1):
		for j in range(m):
			ans = max(ans, arr[k] * b[j])
	ans1 = min(ans1, ans)
print(ans1)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = sorted(map(int, input().split()))
mm = sorted((max(ai * b[0], ai * b[-1]) for ai in a))
mm.remove(max(mm))
print(max(mm))


pt = lambda *a, **k: print(*a, **k, flush=True)
rd = lambda : map(int, input().split())
(n, m) = rd()
an = list(rd())
bn = list(rd())
a1 = max(an)
a2 = min(an)
b1 = max(bn)
b2 = min(bn)
c1 = max(a1 * b1, a1 * b2)
c2 = max(a2 * b1, a2 * b2)
if c1 > c2:
	an.remove(a1)
else:
	an.remove(a2)
r = -4557430888798830399
for i in an:
	for j in bn:
		if i * j > r:
			r = i * j
pt(r)


(n, m) = input().split()
n = int(n)
m = int(m)
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
b.sort()
ans = 10000000000000000000
for i in range(n):
	maxi = -10000000000000000000
	for j in range(n):
		if j != i:
			for k in range(m):
				pr = a[j] * b[k]
				maxi = max(maxi, pr)
	ans = min(ans, maxi)
print(ans)


input()
a = list(map(int, input().split()))
b = list(map(int, input().split()))
print(min((max((x * y for x in a[:i] + a[i + 1:] for y in b)) for i in range(len(a)))))


input()
a = sorted([int(x) for x in input().split()])
b = sorted([int(x) for x in input().split()])
ans = []
for i in a:
	cur = []
	for ii in b:
		cur.append(ii * i)
	ans.append(max(cur))
print(sorted(ans)[-2])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
r1 = 100000000000000000000
for restricted in range(n):
	r2 = -100000000000000000000
	for i in range(n):
		if i == restricted:
			continue
		for j in range(m):
			r2 = max(r2, a[i] * b[j])
	r1 = min(r1, r2)
print(r1)


(m, n) = map(int, input().split())
A = input()
a = A.split()
h = []
g = 0
k = []
for i in range(0, m):
	g = int(a[i])
	h.append(g)
B = input()
b = B.split()
for i in range(0, n):
	g = int(b[i])
	k.append(g)
h.sort()
k.sort()
s1 = max(max(h[1] * k[0], h[-1] * k[-1]), max(h[1] * k[-1], h[-1] * k[0]))
s2 = max(max(h[0] * k[0], h[-2] * k[-1]), max(h[0] * k[-1], h[-2] * k[0]))
ans = min(s1, s2)
print(ans)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
t1 = max(a)
t2 = min(a)
t3 = max(b)
t4 = min(b)
rt1 = max(t1 * t3, t1 * t4)
rt2 = max(t2 * t3, t2 * t4)
if rt1 > rt2:
	a.remove(t1)
	t1 = max(a)
else:
	a.remove(t2)
	t2 = min(a)
print(max(t1 * t3, t2 * t4, t1 * t4, t2 * t3))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

def MAX(a):
	ans = -float('inf')
	for i in b:
		for j in a:
			ans = max(ans, i * j)
	return ans
max_ = {i: -float('inf') for i in range(len(a))}
for i in range(len(a)):
	new_a = a[:i] + a[i + 1:]
	max_[i] = MAX(new_a)
print(min((i for i in max_.values())))


def main():
	(n, m) = [int(x) for x in input().split()]
	a = sorted([int(x) for x in input().split()])
	b = sorted([int(x) for x in input().split()])
	vv = max(a[0] * b[0], a[-1] * b[0], a[0] * b[-1], a[-1] * b[-1])
	if vv == a[0] * b[0] or vv == a[0] * b[-1]:
		a.pop(0)
	else:
		a.pop(-1)
	vv = max(a[0] * b[0], a[-1] * b[0], a[0] * b[-1], a[-1] * b[-1])
	print(vv)

def __starting_point():
	main()
__starting_point()


(a, b) = map(int, input().split())
c = list(map(int, input().split()))
d = list(map(int, input().split()))
x = []
for i in range(a):
	m = -10 ** 18
	for j in range(b):
		m = max(m, c[i] * d[j])
	x.append(m)
x.sort()
print(x[-2])


def solve():
	(N, M) = list(map(int, input().split()))
	T = list(map(int, input().split()))
	B = list(map(int, input().split()))
	res = []
	for n in range(N):
		for m in range(M):
			res.append([T[n] * B[m], n, m])
	res.sort(reverse=True)
	a = T[res[0][1]]
	T.remove(a)
	MAX = -1 * float('inf')
	for t in T:
		for b in B:
			MAX = max(t * b, MAX)
	print(int(MAX))

def __starting_point():
	solve()
__starting_point()


x = input().split()
a = int(x[0])
b = int(x[1])
Tom = [int(u) for u in input().split()]
Ben = [int(u) for u in input().split()]
Tom = sorted(Tom)
Ben = sorted(Ben)
s = []
for i in range(len(Tom)):
	Tom_linshi = Tom[0:i] + Tom[i + 1:len(Tom)]
	s.append(max([n * m for m in Tom_linshi for n in Ben]))
light = int(min(s))
print(light)


kk = lambda : map(int, input().split())
k2 = lambda : map(lambda x: int(x) - 1, input().split())
ll = lambda : list(kk())
(n, m) = kk()
(tt, bb) = (ll(), ll())
fb = sb = 0
maxi = a = b = 0
for i in range(n):
	for j in range(m):
		if i == 0 and j == 0 or tt[i] * bb[j] > maxi:
			(maxi, a, b) = (tt[i] * bb[j], i, j)
(maxi, fst) = (0, True)
for i in range(n):
	if i == a:
		continue
	for j in range(m):
		if fst or tt[i] * bb[j] > maxi:
			(fst, maxi) = (False, tt[i] * bb[j])
print(maxi)


(n, m) = map(int, input().split())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))

def getscore(a, b):
	return max((x * y for x in a for y in b))
print(min((getscore(a[:i] + a[i + 1:], b) for i in range(len(a)))))


(n, m) = map(int, input().split())
a = input().split()
b = input().split()
s = []
aa = []
for i in range(len(a)):
	a[i] = int(a[i])
for i in range(len(b)):
	b[i] = int(b[i])
for i in range(n):
	for l in range(m):
		s.append(a[i] * b[l])
		aa.append(i)
su = -10000000000000000000
for i in range(len(s)):
	if su < s[i]:
		su = s[i]
		n = aa[i]
while True:
	try:
		del s[aa.index(n)]
		del aa[aa.index(n)]
	except:
		break
s.sort()
print(s[-1])


def main():
	(n, m) = list(map(int, input().split()))
	t = list(map(int, input().split()))
	b = list(map(int, input().split()))
	maxs = []
	for ex in range(len(t)):
		maxs.append(max((x * y for (i, x) in enumerate(t) for y in b if i != ex)))
	print(min(maxs))
main()


import sys
f = sys.stdin
(m, n) = (int(number) for number in f.readline().split())
b = [int(number) for number in f.readline().split()]
a = [int(number) for number in f.readline().split()]
b.sort()
a.sort()
mx = a[0] * b[0]
if mx < a[n - 1] * b[m - 1]:
	mx = max(mx, a[n - 1] * b[m - 2])
else:
	mx = max(a[0] * b[1], a[n - 1] * b[m - 1])
if mx < 0:
	if a[0] > 0:
		mx = a[0] * b[m - 2]
	else:
		mx = a[n - 1] * b[1]
print(mx)


(n, m) = map(int, input().split())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
ans1 = []
for i in range(n):
	ans = -10 ** 18 - 1
	for j in range(n):
		if j != i:
			for q in range(m):
				if ans < l1[j] * l2[q]:
					ans = l1[j] * l2[q]
	ans1.append(ans)
print(min(ans1))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
kek = 1000000000000000000
for i in range(n):
	l = 0
	ti = -1000000000000000000
	for j in range(n):
		if j == i:
			continue
		for k in range(m):
			ti = max(a[j] * b[k], ti)
	kek = min(kek, ti)
print(kek)


(n, m) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = []
for i in range(n):
	for j in range(m):
		c.append([a[i] * b[j], i, j])
c = sorted(c)
x = c[-1][1]
while c[-1][1] == x:
	del c[-1]
print(c[-1][0])


class Solution:

	def resolve(self, n, m, a, b):
		prod = [0] * n
		for (i, ai) in enumerate(a):
			mm = ai * b[0]
			for bi in b:
				mm = max(mm, ai * bi)
			prod[i] = mm
		prod.sort()
		return prod[-2]

def __starting_point():
	s = Solution()
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	re = s.resolve(n, m, a, b)
	print(re)
__starting_point()


(m, n) = map(int, input().strip().split(' '))
a = list(map(int, input().strip().split(' ')))
b = list(map(int, input().strip().split(' ')))
a.sort()
b.sort()
if b[0] >= 0:
	a = a[:-1]
elif b[-1] <= 0:
	a = a[1:]
elif a[-1] * b[-1] > a[0] * b[0]:
	a = a[:-1]
else:
	a = a[1:]
if a[0] >= 0:
	bfinal = max(a[-1] * b[-1], a[0] * b[-1])
elif a[-1] <= 0:
	bfinal = max(a[0] * b[0], a[-1] * b[0])
else:
	bfinal = max(a[-1] * b[-1], a[0] * b[0])
print(bfinal)


def main():
	(n, m) = map(int, input().split())
	tommy = list(map(int, input().split()))
	banban = list(map(int, input().split()))
	min_prod = float('inf')
	for i in range(n):
		prod = -1 * float('inf')
		for j in range(n):
			if i != j:
				for k in range(m):
					prod = max(prod, banban[k] * tommy[j])
		min_prod = min(prod, min_prod)
	print(min_prod)
main()


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a = sorted(a)
b = sorted(b)
l = [a[0] * b[0], a[0] * b[-1], a[1] * b[0], a[1] * b[-1], a[-1] * b[0], a[-1] * b[-1], a[-2] * b[0], a[-2] * b[-1]]
if n == 2:
	l = l[:4]
elif n == 3:
	l.pop(-1)
	l.pop(-1)
ind = l.index(max(l)) // 2 * 2
l.pop(ind)
l.pop(ind)
print(max(l))


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = []
x = 0
a.sort()
b.sort()
for t in range(n):
	if a[t] > 0:
		d.append(a[t] * b[-1])
	else:
		d.append(a[t] * b[0])
d.sort()
print(d[-2])


input()
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
b.sort()
if a[-1] * b[-1] > max(a[0] * b[0], a[0] * b[-1]) or a[-1] * b[0] > max(a[0] * b[0], a[0] * b[-1]):
	a.pop()
else:
	a.pop(0)
print(max(a[0] * b[0], a[0] * b[-1], a[-1] * b[-1], a[-1] * b[0]))


def main():
	(n, m) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	x = list(map(int, input().split()))
	m = {}
	for i in l:
		for j in x:
			m[i, j] = i * j
	c = -99798789896868767678678687687
	for i in m:
		if m[i] > c:
			c = m[i]
			y = i[0]
	l.remove(y)
	c = -99798789896868767678678687687
	for i in l:
		for j in x:
			c = max(c, i * j)
	print(c)
main()


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
(x, y) = (max(b), min(b))
result = 100000000000000000000000
for (i, item) in enumerate(a):
	lst = a[:i] + a[i + 1:]
	(mn, mx) = (100000000000000000000000, -100000000000000000000000)
	for (i, numb) in enumerate(lst):
		if mn > numb:
			mn = numb
		if mx < numb:
			mx = numb
	res = max(mn * x, mn * y, mx * x, mx * y)
	if res < result:
		result = res
print(result)


(n, m) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
res = 1000000000000000000000
for i in range(n):
	maxi = -100000000000000000000
	for j in range(n):
		for k in range(m):
			if j == i:
				continue
			maxi = max(maxi, a[j] * b[k])
	res = min(res, maxi)
print(res)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
b.sort()
x = max(a[0] * b[m - 1], a[0] * b[0], a[n - 2] * b[m - 1], a[n - 2] * b[0])
y = max(a[1] * b[m - 1], a[1] * b[0], a[n - 1] * b[m - 1], a[n - 1] * b[0])
print(min(x, y))


def find_max(arr1, arr2, index):
	return sorted([arr1[i] * j for i in range(len(arr1)) for j in arr2 if i != index])[-1]
(n, m) = map(int, input().split())
N = sorted(list(map(int, input().split())))
M = sorted(list(map(int, input().split())))
print(min([find_max(N, M, i) for i in range(n)]))


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
max1 = -10 ** 18
max2 = -10 ** 18
pos = -1
for i in range(n):
	for j in range(m):
		l = a[i] * b[j]
		if l > max1:
			max1 = l
			pos = i
a.pop(pos)
for i in range(n - 1):
	for j in range(m):
		l = a[i] * b[j]
		if l > max2:
			max2 = l
print(max2)


(n, m) = list(map(int, input().split()))
a = [int(x) for x in input().split()]
b = sorted([int(x) for x in input().split()])
lo = b[0]
hi = b[-1]
c = []
for k in range(len(a)):
	best = -1000000000000000001
	for i in range(len(a)):
		if i != k:
			best = max([best, a[i] * lo, a[i] * hi])
	c.append(best)
print(min(c))


import math
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
for i in a:
	d = -math.inf
	for j in b:
		d = max(i * j, d)
	c.append(d)
c.sort(reverse=True)
print(c[1])


import math
(n, m) = input().split()
n = int(n)
m = int(m)
a = []
b = []
temp = []
a = list(map(int, input().split()))
b = list(map(int, input().split()))
mini = math.inf
for i in range(n):
	maxi = -math.inf
	for j in range(n):
		if j != i:
			for k in range(m):
				maxi = max(maxi, a[j] * b[k])
	mini = min(mini, maxi)
print(mini)


(n, m) = map(int, input().strip().split())
a = list(map(int, input().strip().split()))
b = list(map(int, input().strip().split()))
t = int(1e+18) + 1
for i in range(n):
	s = int(-1e+18) - 1
	for j in range(n):
		if i == j:
			continue
		for k in range(m):
			s = max(s, a[j] * b[k])
	t = min(t, s)
print(t)


(n, m) = map(int, input().split())
(m1, m2) = (-1e+18, -1e+18)
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
for i in range(n):
	p = -1e+18
	for j in range(m):
		q = x[i] * y[j]
		if q > p:
			p = q
	if p > m1:
		if m1 > m2:
			m2 = m1
		m1 = p
	elif p > m2:
		if m2 > m1:
			m1 = m2
		m2 = p
print(int(min(m1, m2)))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
l = []
for i in a:
	m = -10000000000000000000
	for j in b:
		m = max(m, i * j)
	l.append(m)
	if len(l) == 3:
		l.sort()
		l.pop(0)
l.sort()
print(l[-2])


(n, m) = input().split()
n = int(n)
m = int(m)
an = list(map(int, input().split()))
bm = list(map(int, input().split()))
mi = 1e+99
pair = -1e+99
for i in range(n):
	pair = -1e+99
	for j in range(m):
		for k in range(n):
			if i != k:
				pair = max(pair, an[k] * bm[j])
	mi = min(mi, pair)
print(mi)


(a, b) = map(int, input().split())
num1 = list(map(int, input().split()))
num2 = list(map(int, input().split()))
ans = []
for i in num1:
	ans.append(max((i * j for j in num2)))
ans.sort()
print(ans[-2])


(n, m) = list(map(int, input().split()))
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
ind = []
ma = -1e+99
for i in range(n):
	for j in range(m):
		if l1[i] * l2[j] > ma:
			ma = l1[i] * l2[j]
			ind = [i]
		elif l1[i] * l2[j] == ma and i not in ind:
			ind.append(i)
if len(ind) > 1:
	print(ma)
else:
	print(max([x * y for x in l1 if x != l1[ind[0]] for y in l2]))


input()
a = list(map(int, input().split()))
b = list(map(int, input().split()))
candi = []
for x in a:
	mx = x * b[0]
	for y in b:
		mx = max(mx, x * y)
	candi.append(mx)
candi.sort()
print(candi[-2])


import sys
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
v = []
for i in range(n):
	ans = -999999999999999999999999
	for j in range(m):
		ans = max(ans, a[i] * b[j])
	v.append(ans)
v = sorted(v)
print(v[n - 2])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
m = -100000000000000000000
for i in b:
	for j in a:
		if j * i > m:
			m = j * i
			k = j
a.remove(k)
m = -100000000000000000000
for i in b:
	for j in a:
		if j * i > m:
			m = j * i
print(m)


from math import sqrt

def ii():
	return int(input())

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

def li():
	return list(mi())

def si():
	return input()
(n, m) = mi()
a = li()
b = li()
ans = []
for i in range(n):
	x = []
	for j in range(m):
		x.append(a[i] * b[j])
	ans.append(max(x))
ans.sort(reverse=True)
print(ans[1])


(n, m) = map(int, input().split())
a = map(int, input().split())
b = map(int, input().split())
a = sorted(a, reverse=True)
b = sorted(b, reverse=True)
res = max(a[0] * b[0], a[-1] * b[-1], a[0] * b[-1], a[-1] * b[0])
if res == a[0] * b[0] or res == a[0] * b[-1]:
	a.remove(a[0])
else:
	a.remove(a[-1])
res = max(a[0] * b[0], a[-1] * b[-1], a[0] * b[-1], a[-1] * b[0])
print(res)


(n, m) = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
res = pow(2, 60)
for i in range(n):
	mx = -pow(2, 60)
	for j in range(n):
		if j != i:
			for k in range(m):
				mx = max(mx, b[k] * a[j])
	res = min(res, mx)
print(res)


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

def brightness(a, b):
	_max = a[0] * b[0]
	for x in a:
		for y in b:
			_max = max(_max, x * y)
	return _max
(n, m) = map(int, input().split())
a = getList()
b = getList()
lenA = len(a)
_min = brightness(a[1:], b)
for i in range(lenA):
	l = a[:i] + a[i + 1:]
	if i == 0:
		_min = brightness(l, b)
	else:
		_min = min(_min, brightness(l, b))
print(_min)


(a, b) = map(int, input().split())
lst1 = list(map(int, input().split()))
lst2 = list(map(int, input().split()))
lst1.sort()
lst2.sort()
lst = lst1[:]
lst1 = lst1[:-1]
n = max(lst1[-1] * lst2[-1], lst1[0] * lst2[0], lst1[0] * lst2[-1], lst1[-1] * lst2[0])
lst1 = lst
lst1 = lst1[1:]
m = max(lst1[-1] * lst2[-1], lst1[0] * lst2[0], lst1[0] * lst2[-1], lst1[-1] * lst2[0])
print(min(n, m))


import os
import sys
from io import BytesIO, IOBase

def main():
	(n, m) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	temp = []
	mxhidden = -1e+100
	hid = 0
	for y in range(m):
		for z in range(n):
			if b[y] * a[z] > mxhidden:
				mxhidden = b[y] * a[z]
				hid = z
	a.pop(hid)
	ans = -1e+100
	for x in range(n - 1):
		for y in range(m):
			ans = max(ans, a[x] * b[y])
	print(ans)
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')
main()


R = lambda : map(int, input().split())
R()
na = list(R())
nb = list(R())
bcm = None
for i in na:
	cm = float('-inf')
	for j in nb:
		cm = max(cm, i * j)
	if bcm is None or cm > bcm[0]:
		bcm = (cm, i)
na.remove(bcm[1])
m = float('-inf')
for i in na:
	for j in nb:
		m = max(m, i * j)
print(m)


(n, m) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
a.sort()
ans = -999999999999999999999999999
while len(a) > 1 and len(b) > 1:
	max = -999999999999999999999999999
	maxa = 0
	maxb = 0
	for i in a:
		for j in b:
			if i * j >= max:
				max = i * j
				maxa = i
	a.remove(maxa)
	if len(a) == 0:
		break
	max = -999999999999999999999999999
	maxa = 0
	maxb = 0
	for i in a:
		for j in b:
			if i * j >= max:
				max = i * j
				maxa = i
				maxb = j
	a.remove(maxa)
	b.remove(maxb)
	if max >= ans:
		ans = max
print(ans)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
for x in a:
	mmax = -10 ** 30
	for y in b:
		z = x * y
		if mmax < z:
			mmax = z
	c.append(mmax)
print(sorted(c)[-2])


from itertools import product
(n, m) = map(int, input().split())
a = sorted(map(int, input().split()))
b = sorted(map(int, input().split()))
res = float('inf')
for i in range(n):
	res = min(res, max((x * y for (x, y) in product(a[:i] + a[i + 1:], b))))
print(res)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
for i in range(n):
	mx = -1e+20
	for j in range(n):
		if j == i:
			continue
		for k in range(m):
			mx = max(mx, a[j] * b[k])
	c.append(mx)
print(sorted(c)[0])


(n, m) = map(int, input().split())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
print(sorted([a[i] * b[-(a[i] > 0)] for i in range(n)])[-2])


(a, b) = input().split(' ')
a1 = list(map(int, input().split(' ')))
b1 = list(map(int, input().split(' ')))
c = []
for i in a1:
	for j in b1:
		c.append([i * j, i])
c.sort()
a1.remove(c[-1][1])
c = []
for i in a1:
	for j in b1:
		c.append(i * j)
c.sort()
print(c[-1])


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
s = [[max(a) * max(b), 'mx'], [min(a) * min(b), 'mi'], [max(a) * min(b), 'mx'], [min(a) * max(b), 'mi']]
s.sort(key=lambda x: x[0], reverse=True)
if s[0][1] == 'mi':
	a.remove(min(a))
else:
	a.remove(max(a))
s = [max(a) * max(b), min(a) * min(b), max(a) * min(b), min(a) * max(b)]
print(max(s))


(n, m) = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
index = 0
ans = -1000000000000000000
for i in range(n):
	for j in range(m):
		if a[i] * b[j] > ans:
			ans = a[i] * b[j]
			index = i
c = []
for i in range(n):
	if i == index:
		continue
	c.append(a[i])
ans = -1000000000000000000
for j in range(n - 1):
	for k in range(m):
		if c[j] * b[k] > ans:
			ans = c[j] * b[k]
print(ans)


m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
r = [[max((ax * bx for bx in b))] for ax in a]
r.sort()
print(int(r[-2][0]))


(n, m) = map(int, input().split())
a = sorted(map(int, input().split()))
b = sorted(map(int, input().split()))
ans = 10 ** 18
for i in range(n):
	cur = -10 ** 18
	for u in range(n):
		if u == i:
			continue
		for v in range(m):
			cur = max(cur, a[u] * b[v])
	ans = min(ans, cur)
print(ans)


(n, m) = map(int, input().split())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
ans = []
for i in arr1:
	ans1 = []
	for j in arr2:
		ans1.append(i * j)
	ans.append(max(ans1))
ans.sort(reverse=True)
print(ans[1])


(n, m) = input().split()
(n, m) = (int(n), int(m))
tom = list((i for i in map(int, input().split())))
bon = list((i for i in map(int, input().split())))
if max(tom) > 0 and min(tom) <= 0:
	if max(bon) > 0 and min(bon) > 0:
		tom.remove(max(tom))
	if max(bon) > 0 and min(bon) <= 0:
		if min(tom) * min(bon) > max(tom) * max(bon):
			tom.remove(min(tom))
		else:
			tom.remove(max(tom))
	if max(bon) <= 0 and min(bon) <= 0:
		tom.remove(min(tom))
if max(tom) > 0 and min(tom) > 0:
	if max(bon) > 0 and min(bon) > 0:
		tom.remove(max(tom))
	if max(bon) > 0 and min(bon) <= 0:
		tom.remove(max(tom))
	if max(bon) <= 0 and min(bon) <= 0:
		tom.remove(min(tom))
if max(tom) <= 0 and min(tom) <= 0:
	if max(bon) > 0 and min(bon) > 0:
		tom.remove(max(tom))
	if max(bon) > 0 and min(bon) <= 0:
		tom.remove(min(tom))
	if max(bon) <= 0 and min(bon) <= 0:
		tom.remove(max(tom))
mt = max(tom)
mnt = min(tom)
mb = max(bon)
mnb = min(bon)
r1 = mt * mb
r2 = mnt * mnb
r3 = mt * mnb
r4 = mnt * mb
res = max(r1, r2, r3, r4)
print(res)


import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A.sort()
B.sort()
ans = 1e+20
for i in range(N):
	A2 = A[:i] + A[i + 1:]
	local_ans = -1e+20
	for a in A2:
		for b in B:
			local_ans = max(local_ans, a * b)
	ans = min(ans, local_ans)
print(ans)


(n, m) = [int(x) for x in input().split()]
lstT = [int(x) for x in input().split()]
lstB = [int(x) for x in input().split()]
z = -9999999999999999999999999999
T = 0
B = 0
for i in range(n):
	for j in range(m):
		if z < lstT[i] * lstB[j]:
			T = i
			B = j
			z = lstT[i] * lstB[j]
lol = -99999999999999999999
for i in range(n):
	for j in range(m):
		if T != i:
			lol = max(lol, lstT[i] * lstB[j])
print(lol)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ma = -10 ** 20
for j in range(n):
	for k in range(m):
		p = a[j] * b[k]
		if p > ma:
			ma = p
			x = j
del a[x]
ma = -10 ** 20
for j in range(n - 1):
	for k in range(m):
		ma = max(ma, a[j] * b[k])
print(ma)


(n, m) = map(int, input().split())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
mx = -100000000000000000000000000000000000
midx = -1
for i in range(n):
	for j in range(m):
		if l1[i] * l2[j] > mx:
			mx = l1[i] * l2[j]
			midx = i
del l1[midx]
mx = -100000000000000000000000000000000000
for i in range(n - 1):
	for j in range(m):
		if l1[i] * l2[j] > mx:
			mx = l1[i] * l2[j]
print(mx)


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
aa = min(a) * min(b)
bb = max(a) * max(b)
cc = min(a) * max(b)
dd = max(a) * min(b)
co = max(aa, bb, cc, dd)
if aa == co or cc == co:
	a.remove(min(a))
else:
	a.remove(max(a))
aa = min(a) * min(b)
bb = max(a) * max(b)
cc = min(a) * max(b)
dd = max(a) * min(b)
print(max(aa, bb, cc, dd))


l = input().split(' ')
(m, n) = [int(i) for i in l]
l1 = [int(i) for i in input().split()]
l2 = [int(i) for i in input().split()]

def search(l1, l2):
	m = l1[0] * l2[0]
	ci = 0
	cj = 0
	for i in range(len(l1)):
		for j in range(len(l2)):
			if l1[i] * l2[j] > m:
				m = l1[i] * l2[j]
				ci = i
				cj = j
	return (m, l1[ci], l2[cj])
(a, b, c) = search(l1, l2)
l1.remove(b)
print(search(l1, l2)[0])


o = lambda : map(int, input().split())
(n, m) = o()
a = sorted(o())
b = sorted(o())
m = -10 ** 25
ans = []
for x in a:
	for y in b:
		ans.append([x * y, x])
ans.sort()
a.remove(ans[-1][1])
ans = []
for x in a:
	for y in b:
		ans.append(x * y)
ans.sort()
print(ans[-1])


def main():
	(N, M) = map(int, input().split())
	A = tuple(map(int, input().split()))
	B = tuple(map(int, input().split()))
	ans = []
	apnd = ans.append
	for i in sorted(A):
		n = -float('inf')
		for j in B:
			n = max(n, i * j)
		apnd(n)
	print(min(max(ans[1:]), max(ans[:-1])))
main()


(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
big = 10 ** 25
small = -10 ** 25
ans = big
for i in range(len(a)):
	tmp = small
	for j in range(len(a)):
		if i == j:
			continue
		for x in b:
			_ = a[j] * x
			if _ > tmp:
				tmp = _
	if tmp < ans:
		ans = tmp
print(ans)


(n, m) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
mn = 10 ** 20
for i in range(n):
	mx = -1 * 10 ** 20
	for j in range(n):
		if j == i:
			continue
		for k in range(m):
			mx = max(mx, a[j] * b[k])
	mn = min(mn, mx)
print(mn)


(n, m) = list(map(int, input().split()))
nl = []
ml = []
nl = list(map(int, input().split()))
ml = list(map(int, input().split()))
nl.sort()
ml.sort()
a = nl[0] * ml[-1]
b = nl[-1] * ml[0]
c = nl[-1] * ml[-1]
d = nl[0] * ml[0]
curr = [a, b, c, d]
if max(curr) == a or max(curr) == d:
	nl.pop(0)
else:
	nl.pop(-1)
a = nl[0] * ml[-1]
b = nl[-1] * ml[0]
c = nl[-1] * ml[-1]
d = nl[0] * ml[0]
curr = [a, b, c, d]
print(max(curr))


(n, m) = map(int, input().split())
b = sorted(map(int, input().split()))
c = sorted(map(int, input().split()))
a = b[0] * c[0]
i_k = 0
for i in range(len(b)):
	for j in range(len(c)):
		if b[i] * c[j] > a:
			a = b[i] * c[j]
			i_k = i
del b[i_k]
a = b[0] * c[0]
for i in range(len(b)):
	for j in range(len(c)):
		if b[i] * c[j] > a:
			a = b[i] * c[j]
print(a)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
b.sort()
max_banban = a[0] * b[0]
Tommy_to_delete = 0
for (i, fst) in enumerate(a):
	for snd in b:
		if fst * snd > max_banban:
			max_banban = fst * snd
			Tommy_to_delete = i
ans = None
for (i, fst) in enumerate(a):
	if i != Tommy_to_delete:
		for snd in b:
			if ans == None or fst * snd > ans:
				ans = fst * snd
print(ans)


from sys import stdin, stdout
(n, m) = map(int, stdin.readline().split())
first = list(map(int, stdin.readline().split()))
second = list(map(int, stdin.readline().split()))
ans = float('inf')
for i in range(n):
	cnt = float('-inf')
	for j in range(m):
		for z in range(n):
			if z == i:
				continue
			cnt = max(cnt, first[z] * second[j])
	ans = min(ans, cnt)
stdout.write(str(ans))


import sys, math
(n, m) = map(int, sys.stdin.readline().split())
a = list(map(int, sys.stdin.readline().split()))
b = list(map(int, sys.stdin.readline().split()))
ans = 10 ** 20
for i in range(n):
	temp = -10 ** 20
	for j in range(n):
		if i != j:
			for k in range(m):
				temp = max(temp, a[j] * b[k])
	ans = min(ans, temp)
print(ans)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
save = []
for i in a:
	mx = -10 ** 19
	for j in b:
		mx = max(mx, i * j)
	save.append(mx)
save = sorted(save)
print(save[-2])


(tommy, banban) = list(map(int, input().split(' ')))
allTommy = sorted(list(map(int, input().split(' '))))
allBanban = sorted(list(map(int, input().split(' '))))
allValues = []
for i in allTommy:
	for j in allBanban:
		allValues.append([i * j, i, j])
allValues.sort()
i = 0
while i < len(allTommy):
	if allTommy[i] == allValues[-1][1]:
		allTommy.pop(i)
		break
	i += 1
newValues = []
for i in allTommy:
	for j in allBanban:
		newValues.append(i * j)
newValues.sort()
print(newValues[-1])


(n, m) = map(int, input().split())
t = list(map(int, input().split()))
b = list(map(int, input().split()))
t = sorted(t, reverse=True)
b = sorted(b, reverse=True)
temp = 0
ans = int(-1e+20)
for i in t:
	for j in b:
		if i * j > ans:
			ans = i * j
			temp = i
t.remove(temp)
print(sorted([i * j for i in t for j in b])[-1])


input()
a = list(map(int, input().split()))
b = list(map(int, input().split()))
k = [max(a), min(a)]
a.remove(max(a))
a.remove(min(a))
c = []
d = []
for i in a:
	for j in b:
		c.append(i * j)
		d.append(i * j)
for i in b:
	c.append(k[0] * i)
for i in b:
	d.append(k[1] * i)
print(min(max(c), max(d)))


(n, m) = map(int, input().split())
tom = list(map(int, input().split()))
ban = list(map(int, input().split()))
a1 = max(tom)
a2 = min(tom)
b1 = max(ban)
b2 = min(ban)
if max(a1 * b1, a1 * b2) <= max(a2 * b1, a2 * b2):
	tom.remove(a2)
else:
	tom.remove(a1)
r = -4557430888798830399
for i in tom:
	for j in ban:
		if i * j > r:
			r = i * j
print(r, flush=True)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 1e+180
for i in range(n):
	val = -1e+180
	for j in range(n):
		if j == i:
			continue
		for t in range(m):
			val = max(val, a[j] * b[t])
	ans = min(ans, val)
print(ans)


(n, m) = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [[0 for i in range(m)] for j in range(n)]
a_max = [0 for i in range(n)]
mu_max_id = 0
a_max[0] = c[0][0] = a[0] * b[0]
for j in range(1, m):
	c[0][j] = a[0] * b[j]
	if c[0][j] > a_max[0]:
		a_max[0] = c[0][j]
for i in range(1, n):
	a_max[i] = c[i][0] = a[i] * b[0]
	for j in range(1, m):
		c[i][j] = a[i] * b[j]
		if c[i][j] > a_max[i]:
			a_max[i] = c[i][j]
	if a_max[i] > a_max[mu_max_id]:
		mu_max_id = i
a.pop(mu_max_id)
ans = a[0] * b[0]
for i in range(n - 1):
	for j in range(m):
		ans = max(ans, a[i] * b[j])
print(ans)


input()
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
b.sort()
ans1 = max(a[-2] * b[-1], a[0] * b[0], a[0] * b[-1], a[-2] * b[0])
ans2 = max(a[-1] * b[-1], a[1] * b[0], a[-1] * b[0], a[1] * b[-1])
print(min(ans1, ans2))


(n, m) = map(int, input().strip().split(' '))
a = list(map(int, input().strip().split(' ')))
b = list(map(int, input().strip().split(' ')))
re = sorted([(max(a) * max(b), max(a)), (min(a) * max(b), min(a)), (max(a) * min(b), max(a)), (min(a) * min(b), min(a))])[-1][1]
a.remove(re)
re = sorted([(max(a) * max(b), max(a)), (min(a) * max(b), min(a)), (max(a) * min(b), max(a)), (min(a) * min(b), min(a))])[-1][0]
print(re)


(m, n) = map(int, input().split())
lst1 = list(map(int, input().split()))
lst2 = list(map(int, input().split()))
lst0 = []
for i in lst1:
	lst0.append(max([i * j for j in lst2]))
ans = sorted(lst0)[-2]
print(ans)


def main():
	(n, m) = map(int, input().split())
	a = map(int, input().split())
	b = list(map(int, input().split()))
	l = []
	for (i, x) in enumerate(a):
		for y in b:
			l.append((x * y, i))
	l.sort(key=lambda x: x[0])
	for x in reversed(l):
		if x[1] != l[-1][1]:
			print(x[0])
			break
main()


(n, m) = [int(x) for x in input().split(' ')]
na = [int(x) for x in input().split(' ')]
nb = [int(x) for x in input().split(' ')]
na.sort()
nb.sort()
ans = -1000000000000000001
store = 0
for i in na:
	for j in nb:
		if i * j > ans:
			ans = max(i * j, ans)
			store = i
na.remove(store)
ans = -1000000000000000001
for i in na:
	for j in nb:
		ans = max(i * j, ans)
print(ans)


def compatible_pair(l1, l2):
	l1 = sorted(l1)
	l2 = sorted(l2)
	return min((max((x * y for x in [l2[0], l2[-1]] for y in l)) for l in [[l1[0], l1[-2]], [l1[1], l1[-1]]]))
input()
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
print(compatible_pair(l1, l2))


(n, m) = map(int, input().split())
arr1 = sorted(map(int, input().split()))
arr2 = sorted(map(int, input().split()))
if arr1[-1] * arr2[-1] > arr1[0] * arr2[0]:
	l = max(arr1[-2] * arr2[-1], arr1[0] * arr2[0])
	if n > 2:
		l = max(l, arr1[1] * arr2[-1])
	if m > 2:
		l = max(l, arr1[-2] * arr2[0])
else:
	l = max(arr1[-1] * arr2[-1], arr1[1] * arr2[0])
	if n > 2:
		l = max(l, arr1[1] * arr2[-1])
	if m > 2:
		l = max(l, arr1[-2] * arr2[0])
print(l)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
res = [[max((a1 * b1 for b1 in b))] for a1 in a]
res.sort()
print(res[-2][0])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 10 ** 18
for i in range(n):
	M = -10 ** 18
	for j in range(n):
		if j == i:
			continue
		for k in range(m):
			M = max(M, a[j] * b[k])
	ans = min(ans, M)
print(ans)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
b.sort()
amin1 = a[0]
amin2 = a[1]
amax1 = a[-1]
amax2 = a[-2]
bmin1 = b[0]
bmin2 = b[1]
bmax1 = b[-1]
bmax2 = b[-2]
a1 = max(amin1 * bmin1, amin1 * bmax1)
a2 = max(amax1 * bmin1, amax1 * bmax1)
x11 = amin2 * bmin1
x12 = amin2 * bmax1
x13 = amax1 * bmax1
x14 = amax1 * bmin1
x1 = max(x11, x12, x13, x14)
x21 = amax2 * bmax1
x22 = amax2 * bmin1
x23 = amin1 * bmin1
x24 = amin1 * bmax1
x2 = max(x21, x22, x23, x24)
if a1 < a2:
	print(x2)
else:
	print(x1)


(n, m) = [int(x) for x in input().split(' ')]
a = [int(x) for x in input().split(' ')]
b = [int(x) for x in input().split(' ')]
r = []
for x in a:
	r.append(max([x * y for y in b]))
r.sort()
print(r[-2])


(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
b.sort()
first = []
for x in a:
	if x > 0:
		first.append(x * b[-1])
	elif x < 0:
		first.append(x * b[0])
	else:
		first.append(0)
ans = 10 ** 25
for i in range(len(a)):
	s = -10 ** 25
	for j in range(len(a)):
		if j != i:
			if first[j] > s:
				s = first[j]
	if s < ans:
		ans = s
print(ans)


n = 0
m = 0
MaxP = 0
A = [0] * 100
B = [0] * 100
MaxV = -99999999999999999999999999999999999999
(n, m) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
for i in range(n):
	for j in range(m):
		if MaxV < A[i] * B[j]:
			MaxP = i
			MaxV = A[i] * B[j]
MaxV = -99999999999999999999999999999999999999999
for i in range(n):
	if i != MaxP:
		for j in range(m):
			if MaxV < A[i] * B[j]:
				MaxV = A[i] * B[j]
print(MaxV)


[n, m] = input().split(' ')
n = int(n)
m = int(m)
lin1 = input().split(' ')
lin2 = input().split(' ')
a = []
b = []
for i in range(n):
	a.append(int(lin1[i]))
for i in range(m):
	b.append(int(lin2[i]))
maxn = -9e+18
for i in range(n):
	for j in range(m):
		if a[i] * b[j] > maxn:
			maxn = a[i] * b[j]
			p1 = i
			p2 = j
maxn = -9e+18
for i in range(n):
	for j in range(m):
		if i == p1:
			continue
		if a[i] * b[j] > maxn:
			maxn = a[i] * b[j]
print(maxn)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
inf = 10 ** 18
ans = inf
for hide in range(n):
	get = -inf
	for i in range(n):
		for j in range(m):
			if i != hide:
				get = max(get, a[i] * b[j])
	ans = min(ans, get)
print(ans)


R = lambda : map(int, input().split())
(n, m) = R()
a = list(R())
b = list(R())
a.sort(reverse=True)
b.sort(reverse=True)
a1 = a[0] * b[0]
a2 = a[0] * b[m - 1]
a3 = a[n - 1] * b[0]
a4 = a[n - 1] * b[m - 1]
if max(a1, a2, a3, a4) == max(a1, a2):
	a = a[1:]
else:
	a = a[:n - 1]
a1 = a[0] * b[0]
a2 = a[0] * b[m - 1]
a3 = a[n - 2] * b[0]
a4 = a[n - 2] * b[m - 1]
print(max(a1, a2, a3, a4))


(n, m) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
res = 1000000000000000000000000000
for i in range(n):
	maxi = -100000000000000000000000
	for j in range(n):
		for k in range(m):
			if j != i:
				maxi = max(maxi, a[j] * b[k])
	res = min(res, maxi)
print(res)


(n, m) = map(int, input().split())
l = sorted(list(map(int, input().split())))
l1 = sorted(list(map(int, input().split())))
ma = l[0] * l1[0]
ma1 = l[1] * l1[0]
for i in range(n - 1):
	for j in range(m):
		ma = max(ma, l[i] * l1[j])
for i in range(1, n):
	for j in range(m):
		ma1 = max(ma1, l[i] * l1[j])
print(min(ma1, ma))


import os
import sys
from io import BytesIO, IOBase

def main():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = float('inf')
	for i in range(n):
		curr = -float('inf')
		for j in range(n):
			if i != j:
				for k in range(m):
					curr = max(curr, a[j] * b[k])
		ans = min(ans, curr)
	print(ans)
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')
main()


(n, m) = [int(k) for k in input().split(' ') if k]
tom = [int(k) for k in input().split(' ') if k]
ban = [int(k) for k in input().split(' ') if k]
maxMultipleAverall = -1000000000 * 10000000000
exclude = n + 1
for i in range(n):
	maxMultiple = -1000000000 * 10000000000
	for j in range(m):
		if tom[i] * ban[j] > maxMultiple:
			secondMaxMultiple = int(maxMultiple)
			maxMultiple = tom[i] * ban[j]
	if maxMultiple > maxMultipleAverall:
		maxMultipleAverall = maxMultiple
		exclude = i
assert 0 <= exclude < n
del tom[exclude]
maxMultipleAverall = -1000000000 * 10000000000
for i in range(n - 1):
	for j in range(m):
		if tom[i] * ban[j] > maxMultipleAverall:
			maxMultipleAverall = tom[i] * ban[j]
print(maxMultipleAverall)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
p = []
for i in a:
	for j in b:
		p.append([i * j, i, j])
p = sorted(p)
del a[a.index(p[-1][1])]
p = []
for i in a:
	for j in b:
		p.append(i * j)
p = sorted(p)
print(p[-1])


from sys import stdin
(n, m) = map(int, stdin.readline().strip().split())
s = list(map(int, stdin.readline().strip().split()))
s1 = list(map(int, stdin.readline().strip().split()))
ans = 10 ** 20
for i in range(n):
	ans1 = -10 ** 20
	for j in range(m):
		for k in range(n):
			if k == i:
				continue
			ans1 = max(ans1, s[k] * s1[j])
	ans = min(ans1, ans)
print(ans)


(n, m) = map(int, input().split())
tn = list(map(int, input().split()))
tm = list(map(int, input().split()))

def absmax():
	return max([max(tm) * max(tn), max(tm) * min(tn), min(tm) * max(tn), min(tm) * min(tn)])
if absmax() == max(tm) * max(tn):
	tn.remove(max(tn))
elif absmax() == max(tm) * min(tn):
	tn.remove(min(tn))
elif absmax() == min(tm) * max(tn):
	tn.remove(max(tn))
else:
	tn.remove(min(tn))
print(absmax())


(n, m) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
res = 10000000000000000007
for i in range(n):
	ans = -10000000000000000007
	for j in range(n):
		if j != i:
			for k in range(m):
				ans = max(ans, a[j] * b[k])
	res = min(res, ans)
print(res)


(n, m) = map(int, input().split())
lst1 = []
for x in input().split():
	lst1.append(int(x))
lst2 = []
for x in input().split():
	lst2.append(int(x))
lst = []
for x in lst1:
	maxi = -10 ** 18
	for y in lst2:
		maxi = max(maxi, x * y)
	lst.append(maxi)
lst.sort()
print(lst[-2])


(tommy, banban) = input().split()
a = []
b = []
a = input().split(' ')
b = input().split(' ')
max = 0
maxac = 0
for x in range(0, int(tommy)):
	a[x] = int(a[x])
for x in range(0, int(banban)):
	b[x] = int(b[x])
for x in range(0, int(tommy)):
	for y in range(0, int(banban)):
		if x == 0 and y == 0:
			max = a[x] * b[y]
			maxac = a[x]
		if a[x] * b[y] > max:
			max = a[x] * b[y]
			maxac = a[x]
a.remove(maxac)
max = 0
for x in range(0, int(tommy) - 1):
	for y in range(0, int(banban)):
		if x == 0 and y == 0:
			max = a[x] * b[y]
		if a[x] * b[y] > max:
			max = a[x] * b[y]
print(max)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c1 = float('inf')
for i in range(n):
	c2 = float('-inf')
	for j in range(n):
		if i != j:
			for k in range(m):
				c2 = max(c2, a[j] * b[k])
	c1 = min(c1, c2)
print(c1)


(n, m) = input().split(' ')
n = int(n)
m = int(m)
masA = input().split(' ')
masB = input().split(' ')
for a in range(0, n):
	masA[a] = int(masA[a])
for b in range(0, m):
	masB[b] = int(masB[b])
max = masA[0] * masB[0]
a = 0
for i in range(0, n):
	for j in range(0, m):
		if max <= masA[i] * masB[j]:
			max = masA[i] * masB[j]
			a = i
del masA[a]
twoMax = masA[0] * masB[0]
for i in range(0, n - 1):
	for j in range(0, m):
		if twoMax <= masA[i] * masB[j]:
			twoMax = masA[i] * masB[j]
print(twoMax)


(m, n) = [int(x) for x in input().split()]
lstM = sorted([int(x) for x in input().split()])
lstN = sorted([int(x) for x in input().split()])
if max([lstM[0] * lstN[h] for h in range(len(lstN))]) > max([lstM[-1] * lstN[h] for h in range(len(lstN))]):
	del lstM[0]
else:
	del lstM[-1]
max_bt = max(max([lstM[0] * lstN[h] for h in range(len(lstN))]), max([lstM[-1] * lstN[h] for h in range(len(lstN))]))
print(max_bt)


(n, m) = map(int, input().split())
an = list(map(int, input().split()))
am = list(map(int, input().split()))
l = []
for i in an:
	mx = i * am[0]
	for j in am:
		mx = max(mx, i * j)
	l.append(mx)
l.sort()
print(l[-2])


(b, m) = map(int, input().split())
boy = map(int, input().split())
man = sorted(map(int, input().split()))
optimal = sorted((max(b * man[0], b * man[-1]) for b in boy))
optimal.remove(max(optimal))
print(max(optimal))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
mx1 = float('-inf')
mx2 = 0
for i in range(n):
	for j in range(m):
		if a[i] * b[j] > mx1:
			mx2 = i
			mx1 = a[i] * b[j]
mx1 = float('-inf')
for i in range(n):
	if i == mx2:
		continue
	for j in range(m):
		mx1 = max(mx1, a[i] * b[j])
print(mx1)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
b.sort()
m1 = max(a[1] * b[0], a[n - 1] * b[m - 1], b[m - 1] * a[1], a[n - 1] * b[0])
m2 = max(a[0] * b[0], a[n - 2] * b[m - 1], b[m - 1] * a[0], a[n - 2] * b[0])
m2 = min(m1, m2)
print(m2)


(n, m) = list(map(int, input().split()))
l = list(map(int, input().split()))
x = list(map(int, input().split()))
d = {}
for i in l:
	for j in x:
		d[i, j] = i * j
c = -9999999999999999999
for i in d:
	if d[i] > c:
		c = d[i]
		y = i[0]
l.remove(y)
c = -9999999999999999999
for i in l:
	for j in x:
		c = max(c, i * j)
print(c)


def CF934A():
	(n, m) = input('').split(' ')
	n = int(n)
	m = int(m)
	x = input('').split(' ')
	y = input('').split(' ')
	mini = 1234567890 ** 2
	for blocked in range(0, len(x)):
		maxi = -1234567890 ** 2
		for i in range(0, len(x)):
			if blocked == i:
				continue
			for v in y:
				maxi = max(maxi, int(x[i]) * int(v))
		mini = min(mini, maxi)
	print(mini)
CF934A()


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
rec = []
for i in range(n):
	tmp = []
	for j in range(m):
		tmp.append(a[i] * b[j])
	rec.append(max(tmp))
rec = sorted(rec)
print(rec[-2])


(nm, n, m) = ([int(i) for i in input().split()], [int(i) for i in input().split()], [int(i) for i in input().split()])
mx = -1000000000000000000000000000000
si = 0
for i in n:
	for j in m:
		if i * j >= mx:
			mx = i * j
			si = i
n.remove(si)
mx = -1000000000000000000000000000000
for i in n:
	for j in m:
		if i * j >= mx:
			mx = i * j
print(mx)


(t, b) = map(int, input().split())
t = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = [-10000000000000000000] * len(t)
for i in range(len(t)):
	ans[i] = t[i] * max(b)
	if t[i] < 0:
		ans[i] = t[i] * min(b)
ans.sort()
print(ans[len(ans) - 2])


def resi_bez(zab, a, b):
	prvi = True
	max = 0
	for vred in b:
		for i in range(len(a)):
			if i != zab and (prvi or vred * a[i] > max):
				prvi = False
				max = vred * a[i]
	return max
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
tr = resi_bez(0, a, b)
for i in range(len(a)):
	tr = min(tr, resi_bez(i, a, b))
print(tr)


(n, m) = map(int, input().split())
l1 = [int(x) for x in input().split()]
l2 = [int(x) for x in input().split()]
r = [[max((a * b for b in l2))] for a in l1]
r.sort()
print(r[-2][0])


s = input().split()
s1 = input().split()
s2 = input().split()
n = int(s[0])
m = int(s[1])
list2 = []
list1 = []
for i in s1:
	list1.append(int(i))
for i in s2:
	list2.append(int(i))
list1.sort()
list2.sort()
cl = []
for i in list1:
	z = []
	for j in list2:
		z.append(i * j)
	cl.append(max(z))
cl.sort()
print(cl[n - 2])


(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
res = [max([ax * bx for bx in b]) for ax in a]
res.sort(reverse=True)
print(res[1])


import math
(m, n) = input().split()
(m, n) = (int(m), int(n))
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
(Q, W) = (A, B)
A.sort()
B.sort()
maxprod = -math.inf
while len(A) > 0 and len(B) > 0:
	val1 = A[0] * B[0]
	val2 = A[0] * B[-1]
	val3 = A[-1] * B[0]
	val4 = A[-1] * B[-1]
	x = max(val1, val2, val3, val4)
	if val1 == x or val2 == x:
		A.pop(0)
		if len(A) == 0 or len(B) == 0:
			break
		val1 = A[0] * B[0]
		val2 = A[0] * B[-1]
		val3 = A[-1] * B[0]
		val4 = A[-1] * B[-1]
		y = max(val1, val2, val3, val4)
		if val1 == y:
			A.pop(0)
			B.pop(0)
			maxprod = max(val1, maxprod)
		elif val2 == y:
			A.pop(0)
			B.pop(-1)
			maxprod = max(maxprod, val2)
		elif val3 == y:
			A.pop(-1)
			B.pop(0)
			maxprod = max(maxprod, val3)
		else:
			A.pop(-1)
			B.pop(-1)
			maxprod = max(maxprod, val4)
	else:
		A.pop(-1)
		if len(A) == 0 or len(B) == 0:
			break
		val1 = A[0] * B[0]
		val2 = A[0] * B[-1]
		val3 = A[-1] * B[0]
		val4 = A[-1] * B[-1]
		y = max(val1, val2, val3, val4)
		if val1 == y:
			A.pop(0)
			B.pop(0)
			maxprod = max(val1, maxprod)
		elif val2 == y:
			A.pop(0)
			B.pop(-1)
			maxprod = max(maxprod, val2)
		elif val3 == y:
			A.pop(-1)
			B.pop(0)
			maxprod = max(maxprod, val3)
		else:
			A.pop(-1)
			B.pop(-1)
			maxprod = max(maxprod, val4)
if maxprod == -math.inf:
	print(max(max(A) * max(B), min(A) * min(B), max(A) * min(B), min(A) * max(B)))
else:
	print(maxprod)


n = input().split()
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
t = []
for i in range(len(a)):
	p = a[0]
	del a[0]
	t.append(max(max(a) * max(b), min(a) * min(b), min(a) * max(b), max(a) * min(b)))
	a.append(p)
print(min(t))