Welcome to Codeforces Stock Exchange! We're pretty limited now as we currently allow trading on one stock, Codeforces Ltd. We hope you'll still be able to make profit from the market!

In the morning, there are $n$ opportunities to buy shares. The $i$-th of them allows to buy as many shares as you want, each at the price of $s_i$ bourles.

In the evening, there are $m$ opportunities to sell shares. The $i$-th of them allows to sell as many shares as you want, each at the price of $b_i$ bourles. You can't sell more shares than you have.

It's morning now and you possess $r$ bourles and no shares.

What is the maximum number of bourles you can hold after the evening?


-----Input-----

The first line of the input contains three integers $n, m, r$ ($1 \leq n \leq 30$, $1 \leq m \leq 30$, $1 \leq r \leq 1000$) — the number of ways to buy the shares on the market, the number of ways to sell the shares on the market, and the number of bourles you hold now.

The next line contains $n$ integers $s_1, s_2, \dots, s_n$ ($1 \leq s_i \leq 1000$); $s_i$ indicates the opportunity to buy shares at the price of $s_i$ bourles.

The following line contains $m$ integers $b_1, b_2, \dots, b_m$ ($1 \leq b_i \leq 1000$); $b_i$ indicates the opportunity to sell shares at the price of $b_i$ bourles.


-----Output-----

Output a single integer — the maximum number of bourles you can hold after the evening.


-----Examples-----
Input
3 4 11
4 2 5
4 4 5 4

Output
26

Input
2 2 50
5 7
4 2

Output
50



-----Note-----

In the first example test, you have $11$ bourles in the morning. It's optimal to buy $5$ shares of a stock at the price of $2$ bourles in the morning, and then to sell all of them at the price of $5$ bourles in the evening. It's easy to verify that you'll have $26$ bourles after the evening.

In the second example test, it's optimal not to take any action.

Difficulty: interview

Starter code:

Solutions:
n, m, r = map(int, input().split())
S = list(map(int, input().split()))
B = list(map(int, input().split()))
x = min(S)
y = max(B)
cnt = r % x
act = r // x
cnt += act * y
print(max(r, cnt))

n, m, r = map(int, input().split())
A = min(list(map(int, input().split())))
B = max(list(map(int, input().split())))
if B <= A:
    print(r)

else:
    ans = r % A + (r // A) * B
    print(ans) 

n,m,r = map(int,input().split())
buy = min(map(int,input().split()))
sell = max(map(int,input().split()))

if buy < sell:
    units = r//buy
    print (units*sell + r - (units*buy))
else:
    print (r)

n, m, r = list(map(int,input().split()))
przed = list(map(int,input().split()))
po = list(map(int,input().split()))
a = min(przed)
b = max(po)
prof = (r // a) * (b - a)
prof = max(prof, 0)
print(r + prof)

n,m,r = list(map(int,input().split()))
s = min(list(map(int,input().split())))
b = max(list(map(int,input().split())))
print(max(r, r % s + (r // s) * b))


n,m,r = list(map(int,input().split()))
S = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

stocks = r//min(S)
left = r%min(S)
newr = left + stocks*max(B)

print(max(r, newr))



n, m, r = list(map(int, input().split()))
s = list(map(int, input().split()))
b = list(map(int, input().split()))
print(max((r // min(s)) * max(b) + (r % min(s)), r))


#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
t=1
for tt in range(t):
    #n=int(input())
    n,m,r= map(int, sys.stdin.readline().split(' '))
    a=list(map(int,sys.stdin.readline().split(' ')))
    b=list(map(int,sys.stdin.readline().split(' ')))
    rem=r%min(a)
    print(max(r,(max(b)*(r//min(a)))+rem))
    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

n, m, r = list(map(int, input().split()))
s = list(map(int, input().split()))
b = list(map(int, input().split()))
u = min(s)
v = max(b)
print(max(r // u * v + r % u, r))


n, m, r = list(map(int, input().split()))
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
mx = 0
ans = r
for x in a:
	ans = max(ans, r // x * max(b) + r % x)
print(ans)


n, m, r = [int(i) for i in input().split(' ')]
s = [int(i) for i in input().split(' ')]
b = [int(i) for i in input().split(' ')]
s.sort()
b.sort()
if b[-1] >= s[0]:
    print((r//s[0]) * (b[-1] - s[0]) + r)
else:
    print(r)

n, m, r = [int(item) for item in input().split()]

s = [int(item) for item in input().split()]
b = [int(item) for item in input().split()]

x = r // min(s)

print(max(r, x * max(b) + r % min(s)))


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

n, m, r = mp()
s = list(mp())
b = list(mp())

t = r // min(s)
o = r % min(s)
p = max(b) * t

print(max(r, p + o))

n, m, r = map(int, input().split())
l1, l2 = list(map(int, input().split())), list(map(int, input().split()))
print(max((r // min(l1)) * max(l2) + r % min(l1), r))

import io, sys, atexit, os

import math as ma
from decimal import Decimal as dec
from itertools import permutations
from random import randint as rand


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


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


def nu ():
	return int (input ())


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


def lcm ( x, y ):
	gg = find_gcd (x, y)
	return (x * y // gg)


mm = 1000000007
yp = 0
def solve ():
	t=1
	for _ in range(t):
		n,m,r=num()
		a=li()
		b=li()
		a.sort()
		b.sort()
		pq=r//a[0]
		print(max(pq*b[m-1]+r%a[0],r))



def __starting_point():
	solve ()
__starting_point()

n, m, r = list(map(int, input().split()))
a = min(list(map(int, input().split())))
b = max(list(map(int, input().split())))
print(max(r, (r//a)*(b-a)+r))


n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = k % min(a)
cur = k // min(a)
if min(a) > max(b):
    print(k)
    return
print(max(b) * cur + ans)

N, M, R= list(map(int, input().split()))

b = sorted(list(map(int,input().split())))
c = sorted(list(map(int,input().split())))

if b[0] < c[-1]:
    cnt = R // b[0]
    R %= b[0]
    R += cnt * c[-1]
print(R)



n,m,r=(int(i) for i in input().split())
s=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
m=min(s)
a=r//m
k=r-m*(r//m)
p=a*max(b)
print(max(p+k,r))


import sys
# gcd
# from fractions import gcd
# from math import ceil, floor
# from copy import deepcopy
from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # make Counter Class
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
# import math
# from functools import reduce
#
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return list(map(int, input().rstrip().split()))
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


n, m, r = mi()
s = lmi()
b = lmi()
s.sort()
b.sort()
b.reverse()
a = s[0]
z = b[0]

print(max(r+(z-a)*(r//a), r))


n, m , r  = map(int, input().split())

s = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

mi = min(s)
ma = max(b)

if mi < ma:
    print((r // mi) * ma + r % mi)
else:
    print(r)

n, m, r = list(map(int,input().split()))
si = list(map(int,input().split()))
bi = list(map(int,input().split()))
print(max(r,r // min(si) * max(bi) + r % min(si)))


#codeforces1150A_live
gi = lambda : list(map(int,input().strip().split()))
n,m,r = gi()
l = gi()
ll = gi()
ans = (r//min(l))*max(ll) + r%min(l)
if ans < r:
	ans = r
print(ans)


n, m, r = map(int, input().split())
buys = list(map(int, input().split()))
sells = list(map(int, input().split()))
min_buys = min(buys)
max_selss = max(sells)
if min_buys < max_selss:
	print(r%min_buys+ r//min_buys*max_selss)
else:
	print(r)