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: interview

Starter code:

Solutions:
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))

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()

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()

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 = 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 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()

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 = list(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 list(max_.values())))


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)

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])

#!/usr/bin/env python3
from sys import stdin, stdout

def rint():
    return list(map(int, stdin.readline().split()))
#lines = stdin.readlines()


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)



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 = -0x3f3f3f3f3f3f3f3f
for i in an:
    for j in bn:
        if i * j > r:
            r = i * j
pt(r)


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 = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))

print(min([max([a[j] * b[k] for j in range(n) for k in range(m) if i != j]) for i in range(n)]))


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))


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])

        
        
        


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 = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(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 = 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 = -0x3f3f3f3f3f3f3f3f
for i in tom:
    for j in ban:
        if i * j > r:
            r = i * j
print(r, flush=True)


# import sys
# sys.stdin = open('in.txt', 'r')

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])


n, m = list(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)
        


# -*- coding: utf-8 -*-
"""
Created on Wed Feb 14 17:39:42 2018

@author: Paras Sharma
"""

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))

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])

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 = 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)