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.

Source: codeforces | Difficulty: EASY
Tags: Implementation

Greedy algorithms


Solutions:
(n, m, r) = [int(x) for x in input().split()]
buy = min([int(x) for x in input().split()])
sell = max([int(x) for x in input().split()])
profit = r // buy * sell + r % buy
print(profit if profit > r else r)


import sys
input = sys.stdin.readline
(N, M, R) = map(int, input().split())
S = list(map(int, input().split()))
B = list(map(int, input().split()))
if R > R // min(S) * max(B) + R % min(S):
	print(R)
else:
	print(R // min(S) * max(B) + R % min(S))


n = list(map(int, input().split()))
s = list(map(int, input().split()))
b = list(map(int, input().split()))
have = n[2]
buy = min(s)
sell = max(b)
if buy >= sell:
	res = have
else:
	res = have + have // buy * (sell - buy)
print(res)


m = list(map(int, input().strip().split()))
a = list(map(int, input().strip().split()))
b = list(map(int, input().strip().split()))
x = min(a)
y = max(b)
if x >= y:
	print(m[2])
else:
	cash = m[2] // x * y + m[2] % x
	print(cash)


import sys
input = sys.stdin.readline
(n, m, r) = map(int, input().split())
s = list(map(int, input().split()))
b = list(map(int, input().split()))
max_price = max(b)
min_price = min(s)
if min_price < max_price:
	print(r + (max_price - min_price) * (r // min_price))
else:
	print(r)


(n, m, r) = map(int, input().split())
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))
a = min(A)
b = max(B)
if a < b:
	s = r // a
	r %= a
	r += b * s
print(r)


valores = input()
valores = valores.split(' ')
r = int(valores[-1])
n = input()
n = n.split(' ')
for i in range(len(n)):
	n[i] = int(n[i])
m = input()
m = m.split(' ')
for i in range(len(m)):
	m[i] = int(m[i])
if min(n) >= max(m):
	print(r)
elif min(n) < max(m):
	print(r - r // min(n) * min(n) + r // min(n) * max(m))


(n, m, r) = map(int, input().split())
lc = list(map(int, input().split()))
ls = list(map(int, input().split()))
lc.sort()
ls.sort(reverse=True)
if lc[0] >= ls[0]:
	print(r)
	exit()
n_shares = r // lc[0]
r -= n_shares * lc[0]
r += n_shares * ls[0]
print(r)


a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
x = a[2]
d = min(b)
ans = x % d + int(x / d) * max(c)
if d < max(c):
	print(ans)
else:
	print(a[2])


(n, m, r) = list(map(int, input().split()))
s = list(map(int, input().split()))
b = list(map(int, input().split()))
s.sort()
b.sort(reverse=True)
a = 0
ptb = s[0]
pts = b[0]
if ptb < pts:
	if s[0] <= r:
		ptb = s[0]
		da = r // ptb
		r -= da * ptb
		a += da
	if a > 0:
		pts = b[0]
		da = a
		r += da * pts
print(r)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
import random
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

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

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def main():
	(n, m, r) = LI()
	a = LI()
	b = LI()
	c = min(a)
	d = max(b)
	if d > c:
		t = r // c
		r -= t * c
		r += t * d
	return r
print(main())


(n, m, r) = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
print(max(r, r + r // min(A) * (max(B) - min(A))))


z = lambda : map(int, input().split())
(a, b, c) = z()
x = min(z())
x1 = max(z())
print(c if x > c or x > x1 else c // x * x1 + c % x)


(n, m, r) = [int(x) for x in input().split()]
buy = [int(x) for x in input().split()]
buy.sort()
sell = [int(x) for x in input().split()]
sell.sort(reverse=True)
remain = r
i = 0
stocks = 0
while i < n:
	if remain / buy[i] != 0:
		stocks += int(remain / buy[i])
		remain = remain % buy[i]
		i += 1
	else:
		break
remain += sell[0] * stocks
if remain < r:
	remain = r
print(remain)


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


(n, m, r) = map(int, input().split())
s = list(map(int, input().split()))
b = list(map(int, input().split()))
if min(s) >= max(b):
	print(r)
	exit()
s = sorted(s)
num = 0
for i in range(n):
	if r >= s[i]:
		num += r // s[i]
		r = r % s[i]
b = sorted(b, reverse=True)
print(max(b) * num + r)


(n, m, r) = map(int, input().split())
buy = list(map(int, input().split()))
sell = list(map(int, input().split()))
buy.sort()
sell.sort()
b_min = min(buy)
s_max = max(sell)
bought = r // b_min
bourels = r % b_min
bourels += bought * s_max
if bourels > r:
	print(bourels)
else:
	print(r)


R = lambda : map(int, input().split())
(n, m, r) = R()
(s, b) = (min(R()), max(R()))
(k, t) = divmod(r, s)
print(max(r, k * b + t))


def main():
	(n, m, r) = map(int, input().split())
	s = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(min_s, max_b) = (min(s), max(b))
	if min_s >= max_b:
		print(r)
		return
	bought_count = r // min_s
	r = r - bought_count * min_s
	selling_price = bought_count * max_b
	r = r + selling_price
	print(r)
main()


(n, m, r) = map(int, input().split())
min_ = 10000.0
max_ = -10000.0
for i in list(map(int, input().split())):
	min_ = min(i, min_)
for i in list(map(int, input().split())):
	max_ = max(i, max_)
print(max(r, r // min_ * max_ + r % min_))


(n, m, r) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = int(r)
w = r // min(a)
r -= w * min(a)
if max(b) > min(a):
	print(r + w * max(b))
else:
	print(d)


(n, x, r) = list(map(int, input().split()))
c = list(map(int, input().split()))
d = list(map(int, input().split()))
k = 0
m = min(c)
print(max([0, (max(d) - m) * (r // m)]) + r)


(n, m, r) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
min_a = min(a)
max_a = max(b)
if min_a >= max_a:
	print(r)
else:
	print(max_a * (r // min_a) + r - r // min_a * min_a)


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


r = lambda : [*map(int, input().split())]
(n, m, k) = r()
a = r()
b = r()
A = min(a)
B = max(b)
if A < B:
	k = k % A + k // A * B
print(k)


[n, m, r] = list(map(int, input().split()))
s = list(map(int, input().split()))
b = list(map(int, input().split()))
price_s = min(s)
price_b = max(b)
if price_b > price_s:
	r = r // price_s * price_b + r % price_s
print(r)


(n, m, r) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = min(a)
y = max(b)
if y > x:
	rem = r % x
	used = r // x
	print(y * used + rem)
else:
	print(r)


import sys
import math
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
mod = 1000000007

def nospace(l):
	ans = ''.join((str(i) for i in l))
	return ans
t = 1
for tt in range(t):
	(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))
if fileoperation:
	sys.stdout = orig_stdout
	sys.stdin = orig_stdin
	inputfile.close()
	outputfile.close()


(n, m, r) = map(int, input().split())
S = sorted([int(x) for x in input().split()])
B = sorted([int(x) for x in input().split()])
(of_shares, burles_left) = (r // S[0], r % S[0])
print(max([r, B[-1] * of_shares + burles_left]))


(m, e, b) = map(int, input().split())
cp = list(map(int, input().split()))
sp = list(map(int, input().split()))
x = min(cp)
y = max(sp)
print(max(b, y * (b // x) + b % x))


(n, m, r) = map(int, input().split())
n1 = list(map(int, input().split()))
m1 = list(map(int, input().split()))
money = r
d = r
if n == 1:
	n2 = n1[0]
else:
	n2 = min(n1)
if m == 1:
	m2 = m1[0]
else:
	m2 = max(m1)
while n2 < m2:
	if d >= n2:
		d = d % n2
		c = (r - r % n2) / n2
		money = money + (m2 - n2) * c
		n1.pop(n1.index(n2))
	elif d != 0 and d > n2 and (n2 < m2):
		d = d % n2
		c = (r - r % n2) / n2
		money = money + (m2 - n2) * c
		n1.pop(n1.index(n2))
	else:
		break
print(int(money))


(n, m, r) = map(int, input().split())
buy = list(map(int, input().split()))
sell = list(map(int, input().split()))
ans = r % min(buy)
ans += r // min(buy) * max(sell)
print(max(ans, 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(' ')]
s.sort()
b.sort()
if b[-1] >= s[0]:
	print(r // s[0] * (b[-1] - s[0]) + r)
else:
	print(r)


(n, m, r) = map(int, input().split())
buys = list(map(int, input().split()))
sell = max(list(map(int, input().split())))
shares = 0
buys.sort()
if buys[0] > sell:
	print(r)
else:
	shares = r // buys[0]
	r = r % buys[0]
	print(r + shares * sell)


(n, m, r) = tuple(map(int, input().split()))
s = list(map(int, input().split()))
b = list(map(int, input().split()))
s_min = min(s)
b_max = max(b)
if b_max <= s_min:
	print(r)
else:
	k = int(r / s_min)
	r += (b_max - s_min) * k
	print(r)


def a_func(d, morning, night):
	mini = min(morning)
	maxi = max(night)
	if maxi < mini:
		return d
	k = d // mini
	d -= mini * k
	d += maxi * k
	return d
(n, m, d) = list(map(int, input().strip().split()))
morning = list(map(int, input().strip().split()))
night = list(map(int, input().strip().split()))
print(a_func(d, morning, night))


R = int(input().split()[-1])
best_buy = min(map(int, input().split()))
best_sell = max(map(int, input().split()))
num_buy = R // best_buy
print(max(R, R + (best_sell - best_buy) * num_buy))


(waysToBuy, waysToSell, UnitsofMoney) = input().split()
UnitsofMoney = int(UnitsofMoney)
buyPrices = input().split()
sellPrices = input().split()
for i in range(len(buyPrices)):
	buyPrices[i] = int(buyPrices[i])
for i in range(len(sellPrices)):
	sellPrices[i] = int(sellPrices[i])
min_buy_price = min(buyPrices)
max_sell_price = max(sellPrices)
if min_buy_price < max_sell_price:
	number_of_shares = UnitsofMoney // min_buy_price
	UnitsofMoney = UnitsofMoney % min_buy_price
	UnitsofMoney += number_of_shares * max_sell_price
	print(UnitsofMoney)
else:
	print(UnitsofMoney)


(N, M, R) = 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) = map(int, input().split())
l = list(map(int, input().split()))
s = list(map(int, input().split()))
x = min(l)
d = int(r / x)
t = r - d * x
y = max(s)
g = t + y * d
print(max(r, g))


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


(n, m, r) = map(int, input().split())
s = sorted(map(int, input().split()))
b = sorted(map(int, input().split()))
if s[0] >= b[-1]:
	print(r)
	quit()
c = r // s[0]
ans = r % s[0]
ans += c * b[-1]
print(ans)


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


(N, M, R) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
minA = min(A)
maxB = max(B)
if maxB < minA:
	print(R)
	exit()
count = R // minA
ans = R + count * (maxB - minA)
print(ans)


(n, m, r) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = r % min(a) + r // min(a) * max(b)
print(x if x > r else r)


(n, m, r) = tuple(map(int, input().split()))
m1 = list(map(int, input().split()))
m2 = list(map(int, input().split()))
min1 = min(m1)
max1 = max(m2)
if min1 < max1:
	print(r // min1 * max1 + r % min1)
else:
	print(r)


(n, m, k) = input().split(' ')
n = int(n)
m = int(m)
k = int(k)
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
aa = min(a)
bb = max(b)
cnt = k // aa
r = k % aa
buy = cnt * bb
if buy + r > k:
	print(bb * cnt + r)
else:
	print(k)


(n, m, r) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
k = min(a)
l = max(b)
if k >= l:
	print(r)
else:
	q = r // k
	t = q * l + r % k
	print(t)


l = input().split()
r = int(l[2])
compra = [int(x) for x in input().split()]
venda = [int(x) for x in input().split()]
v_compra = min(compra)
v_venda = max(venda)
if v_venda <= v_compra:
	print(r)
else:
	cont = r // v_compra * v_venda
	cont += r % v_compra
	print(cont)


def main_funtion():
	(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(' ')]
	min_to_buy = min(s)
	max_to_sell = max(b)
	quantity = r // min_to_buy
	left = r % min_to_buy
	if min_to_buy >= max_to_sell:
		return r
	return left + quantity * max_to_sell
print(main_funtion())


import math
from collections import deque, defaultdict
from sys import stdin, stdout
input = stdin.readline
listin = lambda : list(map(int, input().split()))
mapin = lambda : map(int, input().split())
(n, m, r) = mapin()
a = listin()
b = listin()
ans = (max(b) - min(a)) * (r // min(a))
if ans > 0:
	print(ans + r)
else:
	print(r)


import sys
inp = sys.stdin.readlines()
(a, b, c) = inp[0].split()
mi = min((int(x) for x in inp[1].split()))
ma = max((int(x) for x in inp[2].split()))
x = int(int(c) / mi)
rem = int(c) - x * mi
print(int(max(int(c), rem + x * ma)))


def main():
	(n, m, r) = map(int, input().split())
	bestToBuy = min(list(map(int, input().split())))
	bestToSell = max(list(map(int, input().split())))
	if bestToBuy > bestToSell:
		print(r)
		exit()
	shares = int(r / bestToBuy)
	r -= shares * bestToBuy
	r += shares * bestToSell
	print(r)
main()


(n, m, r) = [int(i) for i in input('').strip().split(' ')]
S = [int(i) for i in input('').strip().split(' ')]
B = [int(i) for i in input('').strip().split(' ')]
(actions, remain) = divmod(r, min(S))
gain = actions * max(B)
if gain - actions * min(S) > 0:
	print(gain + remain)
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)))


(n, m, r) = input().split()
n = int(n)
m = int(m)
r = int(r)
s = list(map(int, input().split()))
b = list(map(int, input().split()))
z = min(s)
k = max(b)
if z > k:
	print(r)
else:
	rem = int(r / z)
	total = r - z * rem
	j = k * rem
	total = total + j
	print(total)


(n, m, r) = map(int, input().split())
buy = min(map(int, input().split()))
cell = max(map(int, input().split()))
if buy >= cell:
	print(r)
else:
	print(r // buy * cell + r % buy)


(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) = map(int, input().split())
li = list(map(int, input().split()))
li1 = list(map(int, input().split()))
print(max(r, r // min(li) * max(li1) + r % min(li)))


(n, m, r) = map(int, input().split())
r1 = r
a = set(map(int, input().split()))
b = set(map(int, input().split()))
mini = min(a)
stk = r // mini
r = r - stk * mini
val = stk * max(b) + r
print(max(r1, val))


(n, m, sum) = map(int, input().split())
a = list(map(int, input().split()))
mi = 99999999999999
mx = 0
for i in range(n):
	mi = min(mi, a[i])
b = list(map(int, input().split()))
for i in range(m):
	mx = max(mx, b[i])
if mi >= mx:
	print(sum)
else:
	print(mx * (sum // mi) + sum % mi)


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


(n, m, p) = map(int, input().split())
x = min(map(int, input().split()))
y = max(map(int, input().split()))
if x < y:
	print(y * (p // x) + p % x)
else:
	print(p)


import collections
import random
import heapq
import bisect
import math
import time

class Solution2:

	def solve(self, A1, A2):
		pass

class Solution:

	def solve(self, buys, sells, r):
		min_buys = min(buys)
		max_sell = max(sells)
		return r + max(0, (max_sell - min_buys) * (r // min_buys))
sol = Solution()
sol2 = Solution2()
for test_case in range(1):
	(N, M, r) = input().split()
	a = [int(c) for c in input().split()]
	s = [int(c) for c in input().split()]
	out = sol.solve(a, s, int(r))
	print(str(out))


n = input().split()
r = int(n[2])
c = r
a = input().split()
b = input().split()
mn = 1000000000000
mx = -1
for i in a:
	mn = min(mn, int(i))
d = r % mn
r //= mn
for i in b:
	mx = max(mx, int(i))
print(max(c, mx * r + d))


(n, m, r) = map(int, input().split())
morn = list(map(int, input().split()))
ev = list(map(int, input().split()))
morn.sort()
ev.sort(reverse=True)
ans = 0
num = r // morn[0]
ans += r - morn[0] * num
ans += num * ev[0]
if ans > r:
	print(ans)
else:
	print(r)


(n, m, r) = map(int, input().split())
S = list(map(int, input().split()))
B = list(map(int, input().split()))
S.sort()
B.sort()
a = r // S[0]
p = a * B[-1]
ans = r % S[0] + p
if ans < r:
	print(r)
else:
	print(ans)


import os
import sys
import math
import heapq
from decimal import *
from io import BytesIO, IOBase
from collections import defaultdict, deque

def r():
	return int(input())

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

def rl():
	return list(map(int, input().split()))
(n, m, a) = rm()
b = rl()
c = rl()
ini = a
b.sort()
c.sort(reverse=True)
shares = 0
shares = a // b[0]
a = a % b[0]
a = a + shares * c[0]
print(max(ini, a))


(n, m, r) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a = sorted(a)
b = sorted(b)
k = r // a[0]
l = r % a[0]
if b[-1] > a[0]:
	print(b[-1] * k + l)
else:
	print(r)


f = list(map(int, input().split()))
n = f[0]
m = f[1]
r = f[2]
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = min(a)
d = max(b)
if c >= d:
	print(r)
else:
	e = int(r / c)
	g = e * d
	e = g + (r - e * c)
	print(e)


(n, m, b) = map(int, input().split())
p = list(map(int, input().split()))
s = list(map(int, input().split()))
k = min(p)
k1 = b // k
d = k1 * k
if b > d:
	r = b - d
else:
	r = 0
z = max(s)
z = k1 * z + r
if b >= z:
	print(b)
else:
	print(z)


(n, m, r) = list(map(int, input().split()))
array_n = list(map(int, input().split()))
array_m = list(map(int, input().split()))
buy = min(array_n)
sell = max(array_m)
numbers_total = r // buy
remaining = r % buy
if numbers_total * sell + remaining < r:
	print(r)
else:
	print(numbers_total * sell + remaining)


datos = input()
d = datos.split()
n = int(d[0])
m = int(d[1])
r = int(d[2])
s = input()
s1 = s.split()
for i in range(len(s1)):
	s1[i] = int(s1[i])
sf = sorted(s1)
b = input()
b1 = b.split()
for i in range(len(b1)):
	b1[i] = int(b1[i])
bf = sorted(b1)
C = int(sf[0])
V = int(bf[-1])
if C < V:
	I = r // C
	Rinv = r - C * I
	G = I * V
	rf = G + Rinv
	print(rf)
else:
	print(r)


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

def main():
	(n, m, r) = input_ints()
	x = min(input_ints())
	y = max(input_ints())
	print(max(r, r % x + r // x * y))
main()


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


func = lambda : map(int, input().split())
(n, m, r) = func()
min1 = min(func())
max1 = max(func())
s = r + max(0, r // min1 * max1 + r % min1 - r)
print(s)


import sys
inf = float('inf')
mod = 1000000007

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

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

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

def int1():
	return int(input())
import string
import math
from itertools import combinations

def main():
	(n, m, r) = get_array()
	cp = get_array()
	sp = get_array()
	m = 0
	cp.sort(reverse=True)
	m = cp[-1]
	z = r // m
	z2 = r % m
	z3 = max(sp) * z + z2
	if z3 > r:
		print(z3)
	else:
		print(r)
main()


(n, m, r) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
b.sort()
temp = r
k = temp // a[0]
temp -= k * a[0]
temp += k * b[-1]
print(max(r, temp))


def main():
	(n, m, r) = (int(x) for x in input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	buy = min(a)
	sell = max(b)
	if sell <= buy:
		print(r)
		return
	res = r // buy * sell + r % buy
	print(res)
	return
main()


(n, m, r) = map(int, input().split())
buy = min(map(int, input().split()))
sell = max(map(int, input().split()))
pro = r // buy * sell + r % buy
print(max(r, pro))


(n, m, r) = map(int, input().split())
s = list(map(int, input().split()))
b = list(map(int, input().split()))
k = min(s)
l = max(b)
if l > k:
	x = int(r / k)
	y = int(r % k)
	print(x * l + y)
else:
	print(r)


(n, m, r) = map(int, input().split())
s_ = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
s = []
for x in s_:
	if x not in s:
		s.append(x)
n = len(s)
if min(s) >= max(b):
	print(r)
else:
	quantity = []
	balance = []
	for i in range(n):
		quantity.append(r // s[i])
		balance.append(r % s[i])
	best_quantity = max(quantity)
	best_balance = -1
	op = quantity.count(best_quantity)
	for q in range(op):
		if best_balance < balance[quantity.index(best_quantity)]:
			best_balance = balance[quantity.index(best_quantity)]
			quantity[quantity.index(best_quantity)] = 0
	print(best_quantity * max(b) + best_balance)


(n, m, r) = map(int, input().split())
s = list(map(int, input().split()))
b = list(map(int, input().split()))
ma = r
for i in s:
	for j in b:
		ma = max(ma, r // i * j + r - r // i * i)
print(ma)


(n, m, r) = list(map(int, input().split()))
bu = list(map(int, input().split()))
se = list(map(int, input().split()))
if min(bu) >= max(se):
	print(r)
else:
	p = max(se) - min(bu)
	u = r // min(bu)
	print(min(bu) * u + p * u + r % min(bu))


def akcii(lst1, lst2, R):
	(c0, c1) = (min(lst1), max(lst2))
	buy = R // c0
	return max(R, R + (c1 - c0) * buy)
(n, m, r) = [int(i) for i in input().split()]
s = [int(x) for x in input().split()]
b = [int(y) for y in input().split()]
print(akcii(s, b, r))


(n, m, r) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
mina = min(a)
maxb = max(b)
if mina < maxb:
	temp = r // mina
	print(temp * maxb + r % mina)
else:
	print(r)


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_char_list = lambda : sys.stdin.readline().strip().split()
get_int = lambda : int(sys.stdin.readline())
pt = lambda x: sys.stdout.write(str(x))
(n, m, r) = get_int_list()
lst1 = get_int_list()
lst2 = get_int_list()
mini = min(lst1)
maxi = max(lst2)
if mini < maxi:
	buy = r // mini
	r = r - buy * mini + buy * maxi
	print(r)
else:
	print(r)


(n, m, r) = map(int, input().strip().split())
S = list(map(int, input().strip().split()))
B = list(map(int, input().strip().split()))
s = min(S)
l = max(B)
if s > l:
	print(r)
else:
	print((l - s) * (r // s) + r)


(n, m, r) = map(int, input().split())
min_price = min(map(int, input().split()))
max_store = max(map(int, input().split()))
count_buy = r // min_price
ost = r % min_price
print(max(count_buy * max_store + ost, r))


import sys
from math import *
from fractions import gcd
readints = lambda : map(int, input().strip('\n').split())
(n, m, b) = readints()
morning = list(readints())
evening = list(readints())
ans = b
buy = min(morning)
sell = max(evening)
profit = (sell - buy) * (b // buy)
ans = max(ans, profit + b)
print(ans)


import sys
import math
import bisect

def main():
	(n, m, p) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	max_val = p
	for i in range(n):
		for j in range(m):
			val = p % A[i] + p // A[i] * B[j]
			max_val = max(max_val, val)
	print(max_val)
main()


while True:
	try:
		(n, m, r) = map(int, input().split())
		s = list(map(int, input().split()))
		b = list(map(int, input().split()))
		sm = min(s)
		sb = max(b)
		if sm < sb:
			print(r % sm + r // sm * sb)
		else:
			print(r)
	except:
		break


(n, m, l) = map(int, input().split())
buying_price = min([int(i) for i in input().split()])
selling_price = max([int(j) for j in input().split()])
bourles = l // buying_price * selling_price + l % buying_price
print(bourles if bourles > l else l)


(n, m, r) = [int(x) for x in input().split()]
s = []
b = []
for i in input().split():
	s.append(int(i))
for i in input().split():
	b.append(int(i))
s = min(s)
b = max(b)
ac = r // s
rr = r % s
result = ac * b + rr
print(max(result, r))


msg = list(map(int, input().split()))
n = msg[0]
m = msg[1]
r = msg[2]
arr = list(map(int, input().split()))
arr1 = list(map(int, input().split()))
arr.sort()
arr1.sort()
arr1.reverse()
buy = int(r / arr[0])
rem = r % arr[0]
rem += buy * arr1[0]
if rem > r:
	print(rem)
else:
	print(r)


s = input().split()
(n, m, r) = (int(s[0]), int(s[1]), int(s[2]))
b = list(map(int, input().split()))
s = list(map(int, input().split()))
b_min = min(b)
s_max = max(s)
if b_min < s_max:
	sc = r // b_min
	rc = r - sc * b_min
	print(rc + sc * s_max)
else:
	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()]
smin = min(s)
bmax = max(b)
nsb = r // smin
rp = r - nsb * smin
if rp + nsb * bmax > r:
	print(rp + nsb * bmax)
else:
	print(r)


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


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


(a, b, c) = [*map(int, input().split())]
buy = [*map(int, input().split())]
sell = [*map(int, input().split())]
a = min(buy)
b = max(sell)
if b <= a:
	print(c)
else:
	no_of_shares = c // a
	remainder = c % a
	sell_money = b * no_of_shares
	total_money = sell_money + remainder
	print(total_money)


(a, c, b) = map(int, input().split())
r = list(map(int, input().split()))
s = list(map(int, input().split()))
a = min(r)
c = max(s)
if c > a:
	x = b // a
	x *= c
	x += b % a
	b = int(x)
print(b)


(n, m, b) = map(int, input().split())
ma = b
arr = list(map(int, input().split()))
ls = list(map(int, input().split()))
if min(arr) < max(ls):
	sh = b // min(arr)
	b -= sh * min(arr)
	b += max(ls) * sh
print(b)


(n, m, r) = [int(x) for x in input().split()]
s = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
p = min(s)
q = max(b)
d = r // p
x = r - d * p + d * q
if x > r:
	print(x)
else:
	print(r)


(n, m, r) = map(int, input().split())
a = list(map(int, input().split()))
s = list(map(int, input().split()))
x = r // min(a)
print(max(x * max(s) + r % min(a), 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)))


from sys import stdin
input = stdin.readline
(n, m, r) = list(map(int, input().split()))
b = list(map(int, input().split()))
s = list(map(int, input().split()))
(buy, sell) = (min(b), max(s))
if buy >= sell:
	print(r)
else:
	(share, remainder) = divmod(r, buy)
	print(share * sell + remainder)


(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())
min_s = min(map(int, input().split()))
max_b = max(map(int, input().split()))
if max_b <= min_s:
	print(r)
else:
	print(r // min_s * max_b + r % min_s)


(n, m, r) = map(int, input().split())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
l1.sort()
l2.sort(reverse=True)
z = r // l1[0]
print(max(z * l2[0] + r % l1[0], r))


(n, m, r) = [int(s) for s in input().split()]
s = [int(a) for a in input().split()]
b = [int(a) for a in input().split()]
if min(s) < max(b):
	print(r // min(s) * max(b) + r % min(s))
else:
	print(r)


import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline

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

def mapinp():
	return map(int, input().split())
(n, m, bour) = mapinp()
a = linp()
b = linp()
c = min(a)
d = max(b)
if c < d:
	pur = bour // c
	ans = bour % c
	ans += pur * d
	print(ans)
else:
	print(bour)


a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
t = min(b)
r = max(c)
if r > t:
	print(int(a[2] / t) * r + int(a[2] % t))
else:
	print(a[2])


(n, m, r) = map(int, input().split())
s = [*map(int, input().split())]
b = [*map(int, input().split())]
ans = r
c = r // min(s)
res = c * max(b)
res += r % min(s)
print(max(ans, res))


def sol(r, buy, sell):
	minBuy = min(buy)
	maxSell = max(sell)
	if maxSell <= minBuy:
		return r
	n = r // minBuy
	profit = (maxSell - minBuy) * n
	return r + profit
[n, m, r] = [int(x) for x in input().split()]
buy = [int(x) for x in input().split()]
sell = [int(x) for x in input().split()]
print(sol(r, buy, sell))


(n, m, r) = map(int, input().split())
mi = min(map(int, input().split()))
mx = max(map(int, input().split()))
print(max(r, r // mi * mx + r % mi))


def main():
	(n, m, r) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	x = r // min(a)
	print(max(r % min(a) + max(b) * x, r))
main()


(n, m, r) = map(int, input().split())
n = [int(j) for j in input().split()]
m = [int(j) for j in input().split()]
x = min(n)
y = max(m)
if y <= x:
	print(r)
else:
	print(r % x + y * (r // x))


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


(n, m, r) = map(int, input().split())
s = [int(i) for i in input().split()]
d = [int(i) for i in input().split()]
c = r // min(s)
c = c * max(d) + r % min(s)
if c >= r:
	print(c)
else:
	print(r)


(n, m, r) = map(int, input().split())
s = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
first = min(s)
second = max(b)
if first < second:
	number = r // first
	r -= number * first
	r += number * second
print(r)


import sys
sys.setrecursionlimit(10 ** 5 + 1)
inf = int(10 ** 20)
max_val = inf
min_val = -inf
RW = lambda : sys.stdin.readline().strip()
RI = lambda : int(RW())
RMI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
RWI = lambda : [x for x in sys.stdin.readline().strip().split()]
(n, m, r) = RMI()
has = r
buy = RMI()
sell = RMI()
bought = r // min(buy)
r -= bought * min(buy)
r += bought * max(sell)
print(max(r, has))


(n, m, r) = map(int, input().split())
s = list(map(int, input().split()))
b = list(map(int, input().split()))
c = r // min(s)
ans = c * max(b)
p = r - c * min(s)
ans += p
if ans < r:
	print(r)
else:
	print(ans)


(n, m, r) = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
ans = r
A.sort()
B.sort()
new = r // A[0] * B[-1] + r % A[0]
print(max(ans, new))


(n, m, r) = map(int, input().split())
s = map(int, input().split())
b = map(int, input().split())
s_min = min(s)
b_max = max(b)
if s_min >= b_max or r < s_min:
	print(r)
else:
	h = r - r // s_min * s_min
	print(r // s_min * b_max + h)


(m, n, k) = map(int, input().split())
l = list(map(int, input().split()))
a = list(map(int, input().split()))
l.sort()
p = k // l[0]
a.sort(reverse=1)
i = p * a[0] + k % l[0]
if k > i:
	print(k)
else:
	print(i)


g = input().split()
n = int(g[0])
m = int(g[1])
r = int(g[2])
a = list(map(int, input().split()))
b = list(map(int, input().split()))
aa = min(a)
ka = r // aa
rr = r - ka * aa
bb = max(b)
res = bb * ka + rr
print(res if res > r else r)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
b.sort(reverse=True)
print(max(k, k - a[0] * (k // a[0]) + b[0] * (k // a[0])))


def func(buy, sell, money):
	buy = sorted(buy)
	sell = sorted(sell)
	if buy[0] > sell[-1]:
		return money
	bought = money // buy[0]
	money -= bought * buy[0]
	money += bought * sell[-1]
	return money
(n, m, r) = map(int, input().split())
buy = list(map(int, input().split()))
sell = list(map(int, input().split()))
print(func(buy, sell, r))


(a, b, c) = map(int, input().split())
x = c
d = list(map(int, input().split()))
e = list(map(int, input().split()))
k = c // min(d)
c = c - min(d) * k
print(max(c + k * max(e), x))


I = lambda : map(int, input().split())
(*_, r) = I()
(s, b) = (min(I()), max(I()))
print(r + r // s * max(0, b - s))


a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
minimum = min(b)
maximum = max(c)
if minimum < maximum:
	answer = a[2] % minimum + a[2] // minimum * maximum
else:
	answer = a[2]
print(answer)


(n, m, r) = map(int, input().split())
s = list(map(int, input().split()))
b = list(map(int, input().split()))
m = 0
ma = max(b)
for i in range(n):
	m = max(m, r // s[i] * ma + r % s[i])
print(max(m, r))


(n, m, r) = map(int, input().split())
min1 = 2000
max2 = -1
temp = 0
list1 = [0] * n
list2 = [0] * m
list1 = input().split()
list2 = input().split()
for i in range(n):
	temp = int(list1[i])
	min1 = min(temp, min1)
for i in range(m):
	temp = int(list2[i])
	max2 = max(temp, max2)
f = 1
if max2 <= min1 or r < min1:
	pass
else:
	temp = r // min1
	r += temp * (max2 - min1)
print(r)


import sys
from math import ceil
input = sys.stdin.readline
(n, m, r) = map(int, input().split())
a = sorted(map(int, input().split()))
b = sorted(map(int, input().split()), reverse=True)
smallest = a[0]
biggest = b[0]
if b[0] > a[0]:
	r += r // smallest * (biggest - smallest)
print(r)


k = input().split()
n = int(k[0])
m = int(k[1])
r = int(k[2])
morn = list(map(int, input().split()))
nig = list(map(int, input().split()))
if min(morn) >= max(nig):
	print(r)
else:
	b = r // min(morn)
	s = b * max(nig)
	k = r - b * min(morn)
	print(s + k)


(n, m, r) = tuple([int(i) for i in input().split()])
c = min([int(i) for i in input().split()])
l = max([int(i) for i in input().split()])
if l > c:
	f = r // c
	f *= l
	print(r - r // c * c + f)
else:
	print(r)


(n, m, r) = map(int, input().split())
s = input().split()
b = input().split()
s = [int(si) for si in s]
b = [int(bi) for bi in b]
mins = min(s)
maxb = max(b)
if mins >= maxb:
	print(r)
else:
	(num, mod) = divmod(r, mins)
	print(num * maxb + mod)


d1 = input('')
d2 = input('')
d3 = input('')
L1 = d1.split()
L2 = d2.split()
L3 = d3.split()
for i in range(len(L1)):
	L1[i] = int(L1[i])
for i in range(len(L2)):
	L2[i] = int(L2[i])
for i in range(len(L3)):
	L3[i] = int(L3[i])
n = L1[2]
if min(L2) >= max(L3):
	print(int(n))
else:
	a = int(n) // int(min(L2)) * int(max(L3)) + int(n) % int(min(L2))
	print(int(a))


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


(n, m, r) = map(int, input().split())
buy = list(map(int, input().split()))
sell = list(map(int, input().split()))
b = min(buy)
s = max(sell)
if b < s:
	ret = r % b + r // b * s
else:
	ret = r
print(ret)


from sys import stdin, stdout
from itertools import combinations
from collections import defaultdict, OrderedDict
import math

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

def stringListIn():
	return [x for x in stdin.readline().split()]

def intIn():
	return int(stdin.readline())

def stringIn():
	return stdin.readline().strip()
(N, M, R) = listIn()
s = listIn()
b = listIn()
if min(s) > max(b):
	print(R)
else:
	minn = min(s)
	maxx = max(b)
	cnt1 = R // minn
	ans = R - cnt1 * minn
	ans += maxx * cnt1
	print(ans)


i = lambda : map(int, input().split())
(n, m, r) = i()
(a, b) = (min(i()), max(i()))
print(max(r, r % a + r // a * b))


s = [int(n) for n in input().split()]
z = [int(n) for n in input().split()]
t = [int(n) for n in input().split()]
k = min(z)
l = max(t)
if k < l:
	p = s[2] // k
	m = s[2] % k
	a = p * l
	print(a + m)
else:
	print(s[2])


def arr(s):
	m = s[0]
	for i in range(1, len(s)):
		if s[i] < m:
			m = s[i]
	return m

def mix(s):
	m = s[0]
	for i in range(1, len(s)):
		if s[i] > m:
			m = s[i]
	return m
(n, m, x) = list(map(int, input().split()))
s = list(map(int, input().split()))
r = list(map(int, input().split()))
min_s = arr(s)
min_r = mix(r)
if min_s < min_r:
	ost = int(x % min_s)
	pol = int(x // min_s * min_r)
	print(ost + pol)
else:
	print(x)


import sys

class Main:

	def __init__(self):
		self.buff = None
		self.index = 0

	def next(self):
		if self.buff is None or self.index == len(self.buff):
			self.buff = self.next_line()
			self.index = 0
		val = self.buff[self.index]
		self.index += 1
		return val

	def next_line(self, _map=str):
		return list(map(_map, sys.stdin.readline().split()))

	def next_int(self):
		return int(self.next())

	def solve(self):
		(n, m, r) = self.next_line(int)
		a = self.next_line(int)
		b = max(self.next_line(int))
		dp = [0 for _ in range(0, r + 1)]
		for aa in a:
			for p in range(0, r - aa + 1):
				dp[p + aa] = max(dp[p + aa], dp[p] + 1)
		ans = r
		for (i, d) in enumerate(dp):
			ans = max(ans, r - i + d * b)
		print(ans)
Main().solve()


(n, m, r) = map(int, input().split())
s = list(map(int, input().split()))
b = list(map(int, input().split()))
m1 = min(s)
buying = r // m1
rem = r % m1
m2 = max(b)
selling_price = buying * m2
if selling_price + rem > r:
	print(selling_price + rem)
else:
	print(r)


S = input().split()
N = int(S[0])
M = int(S[1])
R = int(S[2])
S = input().split()
buy = [0] * N
for i in range(0, N):
	buy[i] = int(S[i])
S = input().split()
sell = [0] * M
for i in range(0, M):
	sell[i] = int(S[i])
buy.sort()
minBuy = buy[0]
sell.sort()
maxSell = sell[-1]
if maxSell > minBuy:
	kolAct = R // minBuy
	R -= kolAct * minBuy
	R += maxSell * kolAct
print(R)


(n, m, cost) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
temp1 = min(a)
temp2 = max(b)
if temp1 < temp2:
	r = cost // temp1
	cost = cost - r * temp1
	s = r * temp2
	cost = cost + s
print(cost)


import sys, math, os
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
from decimal import Decimal
from fractions import Fraction

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

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
INF = 10 ** 9
mod = 10 ** 9 + 7
(n, m, r) = mdata()
s = mdata()
b = mdata()
out(max(r // min(s) * max(b) + r % min(s), r))


import sys

def rint():
	return map(int, sys.stdin.readline().split())
(n, m, r) = rint()
s = list(rint())
b = list(rint())
mins = min(s)
maxb = max(b)
if mins < maxb:
	ans = r // mins * maxb + r % mins
else:
	ans = r
print(ans)


(a, b, c) = input().split()
buy = list(map(int, input().split()))
sell = list(map(int, input().split()))
buyat = min(buy)
buy.remove(buyat)
sellat = max(sell)
number = int(c) // buyat
money = int(c) - number * buyat
if buyat < sellat:
	ans = number * sellat + money
else:
	ans = c
print(ans)


def main():
	(_, _, r) = map(int, input().split())
	s = min(map(int, input().split()))
	b = max(map(int, input().split()))
	if s >= b:
		print(r)
		return
	k = r // s
	reminder = r - s * k
	print(reminder + k * b)
main()


(buy, sell, money) = [int(i) for i in input().split()]
mo = money
cost = min([int(i) for i in input().split()])
count = money // cost
money -= cost * count
selling = max([int(i) for i in input().split()])
money += count * selling
if money > mo:
	print(money)
else:
	print(mo)


def main():
	from sys import stdin, stdout

	def read():
		return stdin.readline().rstrip('\n')

	def read_array(sep=None, maxsplit=-1):
		return read().split(sep, maxsplit)

	def read_int():
		return int(read())

	def read_int_array(sep=None, maxsplit=-1):
		return [int(a) for a in read_array(sep, maxsplit)]

	def write(*args, **kwargs):
		sep = kwargs.get('sep', ' ')
		end = kwargs.get('end', '\n')
		stdout.write(sep.join((str(a) for a in args)) + end)

	def write_array(array, **kwargs):
		sep = kwargs.get('sep', ' ')
		end = kwargs.get('end', '\n')
		stdout.write(sep.join((str(a) for a in array)) + end)
	(n, m, r) = read_int_array()
	min_p = min((int(x) for x in read_array()))
	max_p = max((int(x) for x in read_array()))
	if min_p >= max_p or r < min_p:
		write(r)
	else:
		(d, m) = divmod(r, min_p)
		write(m + d * max_p)
main()


(n, m, r) = map(int, input().split())
b = [int(b) for b in input().split()]
s = [int(s) for s in input().split()]
buy = r // min(b) * min(b)
sell = r // min(b) * max(s)
profit = r - buy + sell
print(profit if profit > r else r)


(n, m, r) = [int(x) for x in input().split()]
s = [int(x) for x in input().split()]
ev = [int(x) for x in input().split()]
a = r // min(s)
print(max(r, a * max(ev) + r % min(s)))


(n, m, r) = map(int, input().split())
S = list(map(int, input().split()))
B = list(map(int, input().split()))
mini = min(S)
maxi = max(B)
if mini >= maxi:
	print(r)
else:
	b = r // mini
	r += (maxi - mini) * b
	print(r)


(n, m, r) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
b.sort(reverse=True)
if a[0] >= b[0]:
	print(r)
	exit()
q = r // a[0]
r -= q * a[0]
r += q * b[0]
print(r)


(n, m, b) = map(int, input().split())
mat = list(map(int, input().split()))
sat = list(map(int, input().split()))
bc = min(mat)
bp = max(sat)
if bp > bc:
	nums = b // bc
	b %= bc
	b += bp * nums
print(b)


(n, m, r) = [int(i) for i in input().split()]
a = min([int(i) for i in input().split()])
b = max([int(i) for i in input().split()])
am = r // a
if b > a:
	print(r - am * a + am * b)
else:
	print(r)


(a, b, c) = map(int, input().split())
d = list(map(int, input().split()))
e = list(map(int, input().split()))
g = min(d)
h = max(e)
x = c - c // g * g
if h > g:
	print(x + c // g * h)
else:
	print(c)


import sys
input = sys.stdin.readline
(n, m, r) = list(map(int, input().split()))
morning = list(map(int, input().split()))
evening = list(map(int, input().split()))
tmp = 0
min_ = min(morning)
tmp = r // min_
tmp2 = r % min_
print(max(r, tmp * max(evening) + tmp2))


(n, m, r) = map(int, input().split())
s = list(map(int, input().split()))
b = list(map(int, input().split()))
sm = min(s)
bm = max(b)
r_old = r
stocks = r // sm
r -= stocks * sm
r += stocks * bm
print(max(r, r_old))


(n, m, r) = list(map(int, input().split()))
buy = min(list(map(int, input().split())))
sell = max(list(map(int, input().split())))
shares = int(r / buy)
res = r + shares * sell - shares * buy
print(max(res, r))


def solve():
	(n, m, r) = map(int, input().split())
	s = [int(k) for k in input().split()]
	b = [int(k) for k in input().split()]
	s.sort()
	b.sort()
	print(max(r // s[0] * b[-1] + r % s[0], r))
solve()


(n, m, r) = [int(x) for x in input().split()]
s = list(map(int, input().split()))
b = list(map(int, input().split()))
x = min(s)
y = max(b)
shares = r // x
bourles = r - shares * x
bourles += shares * y
if bourles > r:
	print(bourles)
else:
	print(r)


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


(n, m, r) = map(int, input().split())
s = [int(s) for s in input().split()]
b = [int(s) for s in input().split()]
mi = min(s)
ma = max(b)
if mi > ma:
	print(r)
else:
	acts = r // mi
	r += acts * (ma - mi)
	print(r)


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


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


(n, m, r) = map(int, input().split())
s = list(map(int, input().split()))
b = list(map(int, input().split()))
g = s[0]
h = b[0]
if len(s) == n and len(b) == m:
	for i in range(len(s) - 1):
		if g > s[i + 1]:
			g = s[i + 1]
		else:
			continue
	for j in range(len(b) - 1):
		if h < b[j + 1]:
			h = b[j + 1]
		else:
			continue
	x = r % g
	num = (r - x) / g
	total = num * h + x
	if total > r:
		print(int(total))
	else:
		print(int(r))


import sys
from sys import stdin, stdout
import bisect
import math
import heapq

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

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
import math

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def main():
	(n, m, k) = cin()
	a = ain()
	b = ain()
	x = min(a)
	y = max(b)
	ans = k % x
	y = y * (k // x)
	print(max(ans + y, k))
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')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


(n, m, r) = map(int, input().split())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
n1 = min(l1)
m1 = max(l2)
if n1 >= m1:
	print(r)
else:
	a = r // n1
	r -= n1 * a
	r += m1 * a
	print(r)


[n, m, r] = list(map(int, input().split()))
s = list(map(int, input().split()))
b = list(map(int, input().split()))
min_s: int = min(s)
max_b: int = max(b)
r_s = r // min_s
if r < max_b * r_s + (r - min_s * r_s):
	print(max_b * r_s + (r - min_s * r_s))
else:
	print(r)


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


(n, m, roubles) = map(int, input().split())
buy_shares = min(map(int, input().split()))
sell_share = max(map(int, input().split()))
number_of_share = int(roubles / buy_shares)
roubles += number_of_share * max(0, sell_share - buy_shares)
print(roubles)


(n, m, r) = map(int, input().split())
s = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
s.sort()
b.sort(key=lambda x: -x)
if s[0] < b[0]:
	number = r // s[0]
	r -= number * s[0]
	r += number * b[0]
print(r)


import sys
input = sys.stdin.readline
from collections import defaultdict as dd
(n, m, r) = map(int, input().split())
l = list(map(int, input().split()))
ll = list(map(int, input().split()))
a = min(l)
b = max(ll)
cou = r // a
left = r % a
tot = left + cou * b
print(max(tot, r))


(a, b, c) = map(int, input().split())
(*a,) = map(int, input().split())
(*b,) = map(int, input().split())
print(max(c, c // min(a) * max(b) + c % min(a)))


(a, b, c) = map(int, input().split())
l = list(map(int, input().split()))
k = list(map(int, input().split()))
if min(l) < max(k):
	print(c // min(l) * max(k) + c % min(l))
else:
	print(c)


def function1():
	line1 = [int(x) for x in str(input()).split()]
	buy_prices = [int(x) for x in str(input()).split()]
	sell_prices = [int(x) for x in str(input()).split()]
	(n, m, r) = (line1[0], line1[1], line1[2])
	buy_price = min(buy_prices)
	sell_price = max(sell_prices)
	if sell_price <= buy_price:
		return r
	remainder = r % buy_price
	shares_bought = r // buy_price
	return shares_bought * sell_price + remainder
print(function1())


import math
import sys
DEBUG = False

def inp():
	return sys.stdin.readline().rstrip()

def dprint(*value, sep=' ', end='\n'):
	if DEBUG:
		print(*value, sep=sep, end=end)

def solve(N, M, R, S, B):
	s = min(S)
	b = max(B)
	if s < b:
		c = R // s
		return R + c * (b - s)
	return R

def main():
	(N, M, R) = [int(e) for e in inp().split()]
	S = [int(e) for e in inp().split()]
	B = [int(e) for e in inp().split()]
	print(solve(N, M, R, S, B))
main()


(n, m, r) = [int(x) for x in input().split()]
arr1 = input().split()
arr2 = input().split()
min1 = int(arr1[0])
max2 = int(arr2[0])
for i in arr1:
	if min1 > int(i):
		min1 = int(i)
for i in arr2:
	if max2 < int(i):
		max2 = int(i)
resp = r
if min1 < max2:
	resp = r // min1 * max2 + r % min1
	r = resp
print(r)


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


entrada = input().split()
n = int(entrada[0])
m = int(entrada[1])
r = int(entrada[2])
comprar = []
vender = []
maior = 0
menor = 0
temp = input().split()
count = 0
for k in temp:
	i = int(k)
	if count == 0:
		menor = i
	elif i < menor:
		menor = i
	count = count + 1
temp = input().split()
count = 0
for l in temp:
	o = int(l)
	if count == 0:
		maior = o
	elif o > maior:
		maior = o
	count = count + 1
if menor >= maior:
	print(r)
else:
	print(r + int(r / menor) * maior - int(r / menor) * menor)


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


(n, m, r) = map(int, input().split())
buy = list(map(int, input().split()))
buy.sort()
sell = list(map(int, input().split()))
sell.sort()
if r // buy[0] * sell[-1] + r % buy[0] >= r:
	print(r // buy[0] * sell[-1] + r % buy[0])
else:
	print(r)


def main():
	(n, m, r) = map(int, input().split())
	buy = list(map(int, input().split()))
	sell = list(map(int, input().split()))
	buy.sort()
	sell.sort(reverse=True)
	shares = r // buy[0]
	total = r % buy[0]
	total += sell[0] * shares
	if total <= r:
		print(r)
	else:
		print(total)
main()


(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) = [int(t) for t in input().split(' ')]
s = [int(t) for t in input().split(' ')]
b = [int(t) for t in input().split(' ')]
print(max(r % min(s) + max(b) * (r // min(s)), r))


ll = lambda : list(map(int, input().split()))
[n, m, r] = ll()
l1 = ll()
l2 = ll()
x1 = min(l1)
x2 = max(l2)
c = r // x1
re = r % x1
p = c * x2
print(max(r, p + re))


(n, m, r) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if min(a) > max(b):
	print(r)
else:
	res = r % min(a)
	q = r // min(a)
	print(max(b) * q + res)


a = input().split()
b = input().split()
s = input().split()
maanie = int(a[2])
buy = 1000
sell = 1
for i in range(len(b)):
	if buy > int(b[i]):
		buy = int(b[i])
for i in range(len(s)):
	if sell < int(s[i]):
		sell = int(s[i])
if buy < sell:
	maanie += maanie // buy * (sell - buy)
print(maanie)


(n, m, r) = map(int, input().split())
a = (int(i) for i in input().split())
b = max((int(i) for i in input().split()))
ans = r
for cost in a:
	ans = max(ans, r // cost * b + r % cost)
print(ans)


def stocks(r, buy, sell):
	smol = min(buy)
	big = max(sell)
	if smol >= big:
		return r
	a = r // smol
	r = r % smol
	r += a * big
	return r
(n, m, r) = list(map(int, input().split()))
buy = list(map(int, input().split()))
sell = list(map(int, input().split()))
print(stocks(r, buy, sell))


(n, m, r) = map(int, input().split())
s = list(map(int, input().split()))
b = list(map(int, input().split()))
p = min(s)
q = max(b)
t = q * (r // p)
print(t + r % p) if t + r % p >= r else print(r)


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


(n, m, r) = list(map(int, input().split()))
S = list(map(int, input().split()))
B = list(map(int, input().split()))
mn = min(S)
mx = max(B)
if mn >= mx:
	print(r)
else:
	sscnt = r // mn
	ssrm = r - sscnt * mn
	print(ssrm + sscnt * mx)


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


(n, m, a) = map(int, input().split())
b = list(map(int, input().split()))
s = list(map(int, input().split()))
b_p = min(b)
s_p = max(s)
print(a // b_p * s_p + a % b_p if b_p < s_p else a)


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


import sys
from itertools import accumulate
input = sys.stdin.readline

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

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

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

def li():
	return list(input().rstrip())
(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))


(buy_times, sell_times, cash) = list(map(int, input().split()))
b = list(map(int, input().split()))
s = list(map(int, input().split()))
if min(b) >= max(s):
	print(cash)
else:
	stocks = cash // min(b)
	cash = cash % min(b)
	profit = stocks * max(s)
	profit += cash
	print(profit)


(n, m, r) = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
s = [int(i) for i in input().split()]
x = b[0]
for i in b:
	if i < x:
		x = i
y = s[0]
for i in s:
	if i > y:
		y = i
print(max(r % x + r // x * y, r))


r = [int(c) for c in input().split()]
ns = min([int(c) for c in input().split()])
mb = max([int(c) for c in input().split()])
if mb <= ns:
	print(r[2])
else:
	print(r[2] % ns + r[2] // ns * mb)


from math import floor

def get_input():
	return list(map(int, input().split()))
r = int(input().split()[2])
s_min = min(get_input())
b_max = max(get_input())
if b_max > s_min:
	s_shares_bought = floor(r / s_min)
	print(r % s_min + s_shares_bought * b_max)
else:
	print(r)


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


(n, m, r) = list(map(int, input().split()))
buy = list(map(int, input().split()))
sell = list(map(int, input().split()))
bestbuy = min(buy)
bestsell = max(sell)
if bestbuy >= bestsell:
	print(r)
else:
	print(r + int(r / bestbuy) * (bestsell - bestbuy))


(n, m, r) = map(int, input().split())
s = list(map(int, input().split()))
b = list(map(int, input().split()))
mns = min(s)
mxb = max(b)
if mns >= mxb:
	print(r)
	exit()
i = 0
while r >= mns:
	r -= mns
	i += 1
res = i * mxb
print(res + r)


nmr = list((int(num) for num in input().split()))
n = list(map(int, input().split()))
m = list((int(num) for num in input().split()))
minimum_of_buying = min(n)
maximum_of_selling = max(m)
if minimum_of_buying > maximum_of_selling:
	print(nmr[2])
else:
	y = int(nmr[2] / minimum_of_buying)
	print(nmr[2] - minimum_of_buying * y + maximum_of_selling * y)


ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(mi())
si = lambda : input()
(n, m, r) = mi()
s = li()
b = li()
(quo, rem) = divmod(r, min(s))
print(max(r, quo * max(b) + rem))


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


import sys
(n, m, r) = map(int, input().split())
s = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
s[0] = min(s)
b[-1] = max(b)
if b[-1] > s[0]:
	print(r - r // s[0] * s[0] + b[-1] * (r // s[0]))
else:
	print(r)


(a, b, c) = map(int, input().split())
t1 = list(map(int, input().split()))
t2 = list(map(int, input().split()))
print(max(c, c % min(t1) + max(t2) * (c // min(t1))))


x = input().split(' ')
(n, m, r) = (int(x[0]), int(x[1]), int(x[2]))
s = [int(x) for x in input().split(' ')]
b = [int(x) for x in input().split(' ')]
bourles = 0
x = min(s)
y = max(b)
if x >= y:
	print(r)
else:
	c = r // x
	print(r - c * x + c * y)


(n, m, r) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
b.sort()
if a[0] < b[m - 1]:
	rr = r // a[0]
	rro = r % a[0]
	rr = rr * b[m - 1]
	print(rr + rro)
else:
	print(r)


(n, m, r) = map(int, input().split())
n1 = list(map(int, input().split()))
m1 = list(map(int, input().split()))
k = r // min(n1) * max(m1) + r % min(n1)
print([r, k][min(n1) <= max(m1)])


(n, m, r) = map(int, input().split())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
ch1 = min(arr1)
ch2 = max(arr2)
print(max(r, r + (ch2 - ch1) * (r // ch1)))


(N, M, R) = map(int, input().split())
S = list(map(int, input().split()))
B = list(map(int, input().split()))
ms = min(S)
mb = max(B)
print(max(mb * (R // ms) + R % ms, R))


(n, m, r) = map(int, input().split())
ar = min(map(int, input().split()))
br = max(map(int, input().split()))
if br > ar:
	print(r // ar * br + r % ar)
else:
	print(r)


(n, m, r) = map(int, input().split())
s = list(map(int, input().split()))
b = list(map(int, input().split()))
s.sort()
b.sort()
if s[0] >= b[m - 1]:
	print(r)
else:
	print(r // s[0] * b[m - 1] + r % s[0])


(n, m, r) = map(int, input().split())
l = list(map(int, input().split()))
k = list(map(int, input().split()))
pri_min = min(l)
qut = r // pri_min
rem = r % pri_min
z = max(k)
if z * qut + rem >= r:
	print(z * qut + rem)
else:
	print(r)


from bisect import bisect_right as br
from bisect import bisect_left as bl
from collections import *
from itertools import *
import functools
import sys
from math import *
from decimal import *
from copy import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 10 ** 5 + 10
MOD = 10 ** 9 + 7

def isprime(n):
	n = abs(int(n))
	if n < 2:
		return False
	if n == 2:
		return True
	if not n & 1:
		return False
	for x in range(3, int(n ** 0.5) + 1, 2):
		if n % x == 0:
			return False
	return True

def mhd(a, b, x, y):
	return abs(a - x) + abs(b - y)

def numIN(x=' '):
	return map(int, sys.stdin.readline().strip().split(x))

def charIN(x=' '):
	return sys.stdin.readline().strip().split(x)

def arrIN():
	return list(numIN())

def dis(x, y):
	a = y[0] - x[0]
	b = x[1] - y[1]
	return (a * a + b * b) ** 0.5

def lgcd(a):
	g = a[0]
	for i in range(1, len(a)):
		g = math.gcd(g, a[i])
	return g

def ms(a):
	msf = -MAX
	meh = 0
	st = en = be = 0
	for i in range(len(a)):
		meh += a[i]
		if msf < meh:
			msf = meh
			st = be
			en = i
		if meh < 0:
			meh = 0
			be = i + 1
	return (msf, st, en)

def res(ans, t):
	print('Case #{}: {} {}'.format(t, ans[0], ans[1]))
(n, m, r) = numIN()
a = arrIN()
b = arrIN()
mn = min(a)
mx = max(b)
if mn < mx:
	x = r // mn
	rem = r - mn * x
	rem += x * mx
	print(rem)
else:
	print(r)


I = lambda : int(input())
IL = lambda : list(map(int, input().split()))
(n, m, r) = IL()
S = IL()
B = IL()
sh = [0] * (r + 1)
for i in range(r):
	for p in S:
		if i + p <= r:
			sh[i + p] = max(sh[i + p], sh[i] + 1)
print(max(r, sh.count(max(sh)) - 1 + sh[r] * max(B)))


a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
m = a[2] // min(b)
p = m * max(c) + a[2] % min(b)
if p >= a[2]:
	print(p)
else:
	print(a[2])


R = lambda : map(int, input().split())
(n, m, r) = R()
(s, b) = (min(R()), max(R()))
print(r + max(0, r // s * (b - s)))


IN = input().split()
n = int(IN[0])
m = int(IN[1])
r = int(IN[2])
IN = input().split()
A = [0] * n
for i in range(0, n):
	A[i] = int(IN[i])
IN = input().split()
B = [0] * m
for i in range(0, m):
	B[i] = int(IN[i])
A.sort()
B.sort()
ans = r
ile = r // A[0]
r -= ile * A[0]
r += ile * B[m - 1]
ans = max(ans, r)
print(ans)


def solve():
	(m, n, r) = map(int, input().split())
	S = list(map(int, input().split()))
	B = list(map(int, input().split()))
	buy = min(S)
	sell = max(B)
	if buy < sell:
		share = r // buy
		return r - buy * share + sell * share
	else:
		return r
print(solve())


linenmr = input()
linenmr = linenmr.split()
linenmr = list(map(int, linenmr))
linen = input()
linen = linen.split()
linen = list(map(int, linen))
linem = input()
linem = linem.split()
linem = list(map(int, linem))
total = linenmr[2]
lowest_price = min(linen)
num_stocks = total // lowest_price
money_left = total % lowest_price
highest_sell = max(linem)
output = highest_sell * num_stocks + money_left
if output < total:
	print(total)
else:
	print(output)


import atexit
import io
import sys
_I_B = sys.stdin.read().splitlines()
input = iter(_I_B).__next__
_O_B = io.StringIO()
sys.stdout = _O_B

@atexit.register
def write():
	sys.__stdout__.write(_O_B.getvalue())

def main():
	(n, m, r) = map(int, input().split())
	s = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s.sort()
	sc = 0
	mb = max(b)
	for i in s:
		if r >= i and i <= mb:
			sc += r // i
			r %= i
		else:
			break
		if r == 0:
			break
	print(r + mb * sc)
main()


(n, m, r) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = min(a)
y = max(b)
ans = r % x
t = r // x
ans += y * t
print(max(r, ans))


def main():
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	mn = min(a)
	mx = max(b)
	ans = k // mn * mx + k % mn
	if ans < k:
		print(k)
	else:
		print(ans)
	return
main()


(n, m, r) = map(int, input().split())
best_buy = min(map(int, input().split()))
best_sell = max(map(int, input().split()))
print(r + max(0, r // best_buy * (best_sell - best_buy)))


list = [int(x) for x in input().split()]
n = list[0]
m = list[1]
r = list[2]
array = [int(x) for x in input().split()]
array_ = [int(x) for x in input().split()]
array.sort()
array_.sort()
c = r // array[0]
o = r
r %= array[0]
r += c * array_[m - 1]
print(max(o, r))


(n, m, r) = map(int, input().split())
lst1 = list(map(int, input().split()))
lst2 = list(map(int, input().split()))
x = min(lst1)
y = max(lst2)
sold = r // x * y
how = r - r // x * x
print(max(r, sold + how))


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


n = [int(i) for i in input().split()]
n = n[2]
buy = min([int(i) for i in input().split()])
sell = max([int(i) for i in input().split()])
qtdB = 0
if buy < sell:
	qtdB = n // buy
	n = n % buy
print(n + sell * qtdB)


def main():
	[n, m, r] = [int(_) for _ in input().split()]
	buy = [int(_) for _ in input().split()]
	sell = [int(_) for _ in input().split()]
	buy.sort()
	sell.sort(reverse=True)
	if buy[0] < sell[0]:
		bought = r // buy[0]
		r = r % buy[0] + bought * sell[0]
	print(r)
main()


line = input().split()
money = int(line[2])
buying_line = map(int, input().split())
selling_line = map(int, input().split())
buy = min(buying_line)
sell = max(selling_line)
amount = money // buy
remain = money % buy
profit = amount * sell + remain
if profit > money:
	print(profit)
else:
	print(money)


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


(n, m, r) = map(int, input().split())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
b1 = min(a1)
b2 = max(a2)
print(max(r, r % b1 + r // b1 * b2))


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


(n, m, r) = map(int, input().split())
arr = list(map(int, input().split()))
arrb = list(map(int, input().split()))
arr.sort()
arrb.sort()
if arr[0] >= arrb[m - 1]:
	print(r)
else:
	buy = r // arr[0]
	r = r - buy * arr[0]
	r = r + buy * arrb[m - 1]
	print(r)


(n, m, r) = map(int, input().split())
buy = [int(x) for x in input().split()]
sell = [int(x) for x in input().split()]
b = min(buy)
s = max(sell)
if s - b > 0:
	freq = r // b
	left = r % b
	print(freq * s + left)
else:
	print(r)


(n, m, r) = map(int, input().split())
n_integers = min(map(int, input().split()))
m_integers = max(map(int, input().split()))
if n_integers >= m_integers:
	print(r)
else:
	print(r % n_integers + r // n_integers * m_integers)


e = list(map(int, input().split()))
n = e[0]
m = e[1]
r = e[2]
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
b = min(l1)
s = max(l2)
bg = 0
fi = r
while r > 0:
	r -= b
	bg += 1
if r < 0:
	bg -= 1
	r += b
if bg * s + r > fi:
	print(bg * s + r)
else:
	print(fi)


import sys
nums = []
for line in sys.stdin:
	nums.append(list(map(lambda x: int(x), line.strip().split(' '))))
money = nums[0][2]
lowest = min(nums[1])
highest = max(nums[2])
if lowest >= highest:
	print(money)
else:
	stocks = money // lowest
	money -= stocks * lowest
	money += stocks * highest
	print(money)


(n, m, r) = map(int, input().split())
b = [int(x) for x in input().split()]
s = [int(x) for x in input().split()]
c = 0
d = 0
l = []
t = []
for i in range(len(b)):
	c = r / b[i]
	l.append(int(c))
p = max(l)
q = p * min(b)
v = p * max(s)
if v > q:
	print(r + (v - q))
else:
	print(r)


import sys, os
f = lambda : list(map(int, input().split()))
if 'local' in os.environ:
	sys.stdin = open('./input.txt', 'r')

def solve():
	(n, m, r) = f()
	s = f()
	b = f()
	s = sorted(s)
	b = sorted(b, reverse=True)
	buy = r // s[0]
	print(max(r - buy * s[0] + buy * b[0], r))
solve()


(n, m, r) = map(int, input().split())
s = sorted(list(map(int, input().split())))
b = max(list(map(int, input().split())))
money = r
i = 0
a = 0
while i < n and r // s[i] > 0:
	a += r // s[i]
	r -= s[i] * (r // s[i])
	i += 1
print(max(money, r + a * b))


(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()
buy = s[0]
amt = r // buy
rem = r - amt * buy
rem += amt * b[-1]
print(max(r, rem))


(n, m, r) = map(int, input().split())
s = [*map(int, input().split())]
p = [*map(int, input().split())]
mm = min(s)
yy = max(p)
qq = r // mm
print(max(qq * yy + r % mm, r))


(n, m, r) = 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, b) = map(int, input().split())
import math
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
if min(a1) < max(a2):
	s = math.floor(b / min(a1))
	b -= min(a1) * s
	b += s * max(a2)
print(b)


r = int(input().split()[2])
mi = min([int(x) for x in input().split()])
mx = max([int(x) for x in input().split()])
print(max(r, r // mi * mx + r % mi))


(n, m, r) = map(int, input().split())
s = list(map(int, input().split()))
b = list(map(int, input().split()))
indmin = 0
indmax = 0
for i in range(1, n):
	if s[i] < s[indmin]:
		indmin = i
for i in range(1, m):
	if b[i] > b[indmax]:
		indmax = i
print(max(r, r // s[indmin] * b[indmax] + r % s[indmin]))


r = int(input().split()[2])
a = min([int(x) for x in input().split()])
b = max([int(x) for x in input().split()]) - a
print(r // a * max(0, b) + r)


import math
(n, m, r) = map(int, input().split())
s = []
ins = input()
s = ins.split()
b = []
ins = input()
b = ins.split()
for i in range(len(s)):
	s[i] = int(s[i])
for i in range(len(b)):
	b[i] = int(b[i])
buycost = min(s)
sellcost = max(b)
if buycost <= sellcost:
	amount = int(math.floor(r / buycost))
	r += amount * (sellcost - buycost)
print(r)


(n, m, r) = list(map(int, input().split()))
mor = list(map(int, input().split()[:n]))
eve = list(map(int, input().split()[:m]))
buy = int(r / min(mor))
rem = r % min(mor)
sell = buy * max(eve)
total = sell + rem
if min(mor) > max(eve):
	print(r)
else:
	print(total)


(n, m, r) = map(int, input().strip().split())
buys = list(map(int, input().strip().split()))
sells = list(map(int, input().strip().split()))
initial = r
minBuy = min(buys)
maxSell = max(sells)
shares = r // minBuy
r = r % minBuy
r += maxSell * shares
print(max(r, initial))


R = lambda : map(int, input().split())
(n, m, r) = R()
s = min(R())
b = max(R())
if b <= s:
	print(r)
else:
	print(r // s * b + r % s)


(n, m, r) = [int(elm) for elm in input().split(' ')]
s = [int(elm) for elm in input().split(' ')]
b = [int(elm) for elm in input().split(' ')]
s_min = min(s)
b_max = max(b)
if s_min < b_max:
	buy_n = r // s_min
	nokori = r - buy_n * s_min
	out = nokori + b_max * buy_n
else:
	out = r
print(out)


def main():
	(n, m, r) = map(int, input().split())
	s = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	smin = min(s)
	bmax = max(b)
	ans = 0
	if bmax <= smin:
		ans = r
	else:
		x = r // smin
		ans = r - smin * x + bmax * x
	print(ans)
main()


(n, m, r) = map(int, input().split())
buy = min(list(map(int, input().split())))
sell = max(list(map(int, input().split())))
if buy < sell:
	res = r % buy + r // buy * sell
else:
	res = r
print(res)


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


(N, M, B) = map(int, input().split())
s = list(map(int, input().split()))
b = list(map(int, input().split()))
ff = min(s)
ss = max(b)
rem = B % ff
rem += ss * (B // ff)
print(rem if rem > B else B)


(n, m, r) = map(int, input().split())
t1 = r
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
x = min(a1)
total = r // x
r -= total * x
r += total * max(a2)
print(max(t1, r))


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


(n, m, r) = [int(i) for i in input().split()]
buy = [int(i) for i in input().split()]
sell = [int(i) for i in input().split()]
print(max(r // min(buy) * max(sell) + (r - r // min(buy) * min(buy)), r))


(n, m, r) = (int(x) for x in input().split())
s = list(map(int, input().split()))
b = list(map(int, input().split()))
kai = r // min(s)
uri = kai * max(b)
print(max(r - min(s) * kai + uri, r))


(n, m, r) = map(int, input().split())
buyingOptions = list(map(int, input().split()))
sellingOptions = list(map(int, input().split()))
minBuyingPrice = min(buyingOptions)
maxSellingPrice = max(sellingOptions)
if maxSellingPrice > minBuyingPrice:
	shares = r // minBuyingPrice
	print(r - shares * (minBuyingPrice - maxSellingPrice))
else:
	print(r)


(n, m, r) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = r
mn = min(a)
mx = max(b)
temp = r
i = 0
while temp >= mn:
	temp = temp - mn
	i += 1
	ans = max(ans, temp + i * mx)
print(ans)


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


(n, m, r) = map(int, input().split())
l1 = [int(x) for x in input().split()]
l2 = [int(x) for x in input().split()]
r = max(r, r - r // min(l1) * min(l1) + r // min(l1) * max(l2))
print(r)


(n, m, r) = map(int, input().split())
s = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
s.sort()
bm = max(b)
poc = 0
i = 0
while r > 0 and i < n:
	za_kolko = s[i]
	if za_kolko >= bm:
		break
	k = r // za_kolko
	poc += k
	r %= za_kolko
	i += 1
print(poc * bm + r)


(x, y, z) = map(int, input().split())
gained_stock = map(int, input().split())
sell_stock = map(int, input().split())
x = min(gained_stock)
y = max(sell_stock)
ans = 0
if y >= x:
	ans = z // x * y + z % x
else:
	ans = z
print(ans)


temp = input()
ar = temp.split()
n = int(ar[0])
m = int(ar[1])
r = int(ar[2])
temp = input()
s = temp.split(' ')
temp = input()
b = temp.split(' ')
min = int(s[0])
for x in s:
	if int(x) < min:
		min = int(x)
share = int(r / min)
bourles = r - min * share
max = 0
for x in b:
	if int(x) > max:
		max = int(x)
bourles += max * share
if bourles > r:
	print(bourles)
else:
	print(r)


(n, m, r) = list(map(int, input().split()))
s = list(map(int, input().split()))
b = list(map(int, input().split()))
s_min = min(s)
b_max = max(b)
if s_min >= b_max:
	print(r)
else:
	number = r // s_min
	cha = r - number * s_min
	out = number * b_max + cha
	print(out)


import math
x = [int(y1) for y1 in input().split(' ')]
x1 = [int(y2) for y2 in input().split(' ')]
x2 = [int(y3) for y3 in input().split(' ')]
x1 = sorted(x1)
x2 = sorted(x2)
k = math.floor(x[2] / x1[0])
q = k * x2[len(x2) - 1] + (x[2] - k * x1[0])
if q >= x[2]:
	print(q)
else:
	print(x[2])


(n, m, r) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = min(A)
b = max(B)
if b - a > 0:
	print(r // a * b + r % a)
else:
	print(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)
	exit()
print(max(b) * cur + ans)


(n, m, r) = [int(i) for i in input().split(' ')]
nis = [int(i) for i in input().split(' ')]
mis = [int(i) for i in input().split(' ')]
min_n = min(nis)
max_m = max(mis)
shares = r // min_n
r_rem = r % min_n
profit = shares * max_m + r_rem
print(max(profit, r))


(n, m, k) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
mi = min(A)
ma = max(B)
print(k + k // mi * max(0, ma - mi))


(n, m, r) = map(int, input().split())
gm = list(map(int, input().split()))
gn = list(map(int, input().split()))
mn = min(gm)
s = r // mn
c = r % mn
rez = c + max(gn) * s
if min(gm) > max(gn):
	print(r)
else:
	print(rez)


(n, m, r) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
mb = min(a)
ms = max(b)
if ms > mb:
	sh = r // mb
	r = r % mb
	r = r + ms * sh
print(r)


import heapq
(n, m, r) = map(int, input().split())
a = [int(o) for o in input().split()]
b = [int(o) for o in input().split()]
h = []
if min(a) >= max(b):
	print(r)
else:
	a = sorted(a)
	i = 0
	ts = 0
	while i < n and a[i] <= max(b) and (r > 0):
		ts += r // a[i]
		r %= a[i]
		i += 1
	print(ts * max(b) + r)


r = int(input().split()[2])
m = min([int(i) for i in input().split()])
print(max(r // m * max([int(i) for i in input().split()]) + r % m, r))


(n, m, r) = map(int, input().split())
s = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
ans = 0
for i in range(n):
	for j in range(m):
		ans = max(r // s[i] * b[j] - r // s[i] * s[i], ans)
print(ans + r)


(a, b, c) = [int(i) for i in input().split()]
d = [int(i) for i in input().split()]
e = [int(i) for i in input().split()]
sums = c
f = min(d)
g = int(c // f)
sums = sums - g * f
h = max(e)
i = h * g
sums = sums + i
if sums >= c:
	print(sums)
else:
	print(c)


(n, m, r) = map(int, input().split())
x1 = list(map(int, input().split()))
x2 = list(map(int, input().split()))
if min(x1) >= max(x2):
	print(r)
else:
	ans = r // min(x1)
	r = r % min(x1)
	print(max(x2) * ans + r)


(n, m, k) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
x = k // min(A)
r = k % min(A)
y = x * max(B)
if y + r > k:
	print(y + r)
else:
	print(k)


import sys
import copy
sys.setrecursionlimit(1000000)
(n, m, r) = map(int, input().split())
s = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
minV = min(s)
maxV = max(b)
ans = r
if minV < maxV:
	d = ans // minV
	ans -= d * minV
	ans += maxV * d
print(ans)


kk = lambda : map(int, input().split())
k2 = lambda : map(lambda x: int(x) - 1, input().split())
ll = lambda : list(kk())
(n, m, r) = kk()
(mi, ma) = (min(kk()), max(kk()))
print(max(r, r % mi + ma * (r // mi)))


I = lambda : int(input())
IL = lambda : list(map(int, input().split()))
(n, m, r) = IL()
S = IL()
B = IL()
print(r // min(S) * max(*B, min(S)) + r % min(S))


import collections
import time
import os
import sys
import bisect
import heapq
(N, M, R) = map(int, input().split())
S = min([int(x) for x in input().split()])
T = max([int(x) for x in input().split()])
ans = T * (R // S) + R % S
print(max(R, ans))


nmr = input().split()
n = int(nmr[0])
m = int(nmr[1])
r = int(nmr[2])
s = [int(k) for k in input().split()]
b = [int(k) for k in input().split()]
lowS = min(s)
highB = max(b)
if highB > lowS:
	stocksBought = r // lowS
	profit = (highB - lowS) * stocksBought
	print(r + profit)
else:
	print(r)


i = lambda : map(int, input().split())
(_, _, r) = i()
a = min(i())
b = max(a, *i())
print(r // a * b + r % a)


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())
ns = set((int(i) for i in input().split()))
ms = set((int(i) for i in input().split()))
ns = sorted(ns)
ms = sorted(ms)[::-1]
if ns[0] < ms[0]:
	shares = r // ns[0]
	profit = ms[0] * shares - ns[0] * shares
	print(profit + r)
else:
	print(r)


import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

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

def F():
	return float(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def main():
	(n, m, r) = LI()
	l1 = LI()
	l2 = LI()
	l1.sort()
	l2.sort()
	x = r // l1[0]
	_r = r - x * l1[0]
	y = x * l2[-1]
	return max(r, _r + y)
print(main())


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


(n, m, r) = map(int, input().split())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
Min = min(A)
X = r // Min
Rem = r % Min
Max = max(B)
Y = X * Max
Y += Rem
if Y > r:
	print(Y)
else:
	print(r)


a = list(map(int, input().split()))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())), reverse=True)
money = a[2]
gain = 0
for i in range(min(a[0], a[1])):
	if c[i] - b[i] > 0:
		stocks = money // b[0]
		money -= stocks * b[0]
		gain += c[0] * stocks
print(money + gain)


def main():
	(n, m, r) = list(map(int, input().split()))
	asks = list(map(int, input().split()))
	bids = list(map(int, input().split()))
	if max(bids) > min(asks):
		max_hold = r // min(asks)
		max_profit = max_hold * (max(bids) - min(asks))
		print(r + max_profit)
	else:
		print(r)
main()


import itertools

def main():
	(n, m, r) = [int(v) for v in input().split()]
	buy = [int(v) for v in input().split()]
	sell = [int(v) for v in input().split()]
	if min(buy) >= max(sell):
		print(r)
	else:
		print(r // min(buy) * max(sell) + r % min(buy))
main()


(n, m, r) = map(int, input().split())
prev = r
s = list(map(int, input().split()))
b = list(map(int, input().split()))
s_min = min(s)
shares = r // s_min
r -= shares * s_min
b_max = max(b)
r += shares * b_max
print(max(r, prev))


(n, m, r) = [int(x) for x in input().split(' ')]
buy = sorted([int(x) for x in input().split(' ')])
sell = sorted([int(x) for x in input().split(' ')])
low = buy[0]
high = sell[-1]
if low > high:
	print(r)
else:
	a = r // low
	rest = r % low
	print(rest + a * high)


x = input()
xx = x.split()
n = int(xx[0])
m = int(xx[1])
r = int(xx[2])
rr = r
x = input()
morning = x.split()
for i in range(0, n):
	morning[i] = int(morning[i])
x = input()
night = x.split()
for i in range(0, m):
	night[i] = int(night[i])
mm = min(morning)
nn = max(night)
f = r // mm
r -= f * mm
r += f * nn
if r > rr:
	print(r)
else:
	print(rr)


import io, sys, atexit, os
import math as ma
from sys import exit
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))
solve()


(n, m, r) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a_min = min(a)
b_max = max(b)
if a_min < b_max:
	buy = r // a_min
	ans = buy * b_max + r % a_min
	print(ans)
else:
	print(r)


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


for _ in range(1):
	(a, b, c) = map(int, input().split())
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	p = min(x)
	q = max(y)
	if p >= q:
		print(c)
	else:
		print(c // p * q + c % p)


(n1, n2, k) = map(int, input().split())
m = map(int, input().split())
e = map(int, input().split())
mi = min(m)
ma = max(e)
n = k // mi
left = k % mi
if ma > mi:
	print(ma * n + left)
else:
	print(k)


(n, m, r) = map(int, input().split())
nx = list(map(int, input().split()))
mx = list(map(int, input().split()))
mi = min(nx)
ma = max(mx)
if mi > ma:
	print(r)
else:
	z = r - r // mi * mi
	share = r // mi
	print(share * ma + z)


(n, m, ans) = map(int, input().split())
l = list(map(int, input().split()))
s = list(map(int, input().split()))
ma = max(s)
mi = min(l)
if ma > mi:
	print(ans // mi * ma + ans % mi)
else:
	print(ans)


(n, m, r) = (int(x) for x in input().split())
s = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
money_b = r % min(s)
num_stocks = int(r / min(s))
money_made = max(b) * num_stocks
money = money_made + money_b
print(max(money, r))


def mai():
	(a, b, c) = input().split()
	n = int(a)
	m = int(b)
	tk = int(c)
	share = 0
	s_price = [0 for i in range(m)]
	b_price = [0 for i in range(n)]
	a = input().split()
	for i in range(n):
		b_price[i] = int(a[i])
	a = input().split()
	for j in range(m):
		s_price[j] = int(a[j])
	s_price.sort(reverse=True)
	b_price.sort()
	if s_price[0] < b_price[0]:
		print(tk)
		return
	else:
		share = int(tk / b_price[0])
		b = tk % b_price[0]
		tk = tk - share * b_price[0]
	s = share * s_price[0]
	print(tk + s)
mai()


(n, m, r) = map(int, input().split())
s = list(map(int, input().split()))
b = list(map(int, input().split()))
if min(s) < max(b) and r >= min(s):
	k = r // min(s)
	ans = k * max(b) + r % min(s)
	print(ans)
if min(s) >= max(b):
	print(r)
if min(s) < max(b) and r < min(s):
	print(r)


(n, m, r) = map(int, input().split())
s = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = r
buy = r // min(s)
r -= min(s) * buy
print(max(buy * max(b) + r, 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()]
m = min(s)
a = r // m
k = r - m * (r // m)
p = a * max(b)
print(max(p + k, r))


(n, m, x) = map(int, input().split())
datn = list(map(int, input().split()))
datm = list(map(int, input().split()))
if max(datm) < min(datn):
	print(x)
else:
	(a, res) = divmod(x, min(datn))
	res += a * max(datm)
	print(res)


(n, m, r) = map(int, input().split())
l = list(map(int, input().split()))
k = list(map(int, input().split()))
c = r // min(l)
d = c * max(k) + r % min(l)
print(max(r, d))


(n, m, r) = map(int, input().split(' '))
sarr = list(map(int, input().split(' ')))
barr = list(map(int, input().split(' ')))
smin = min(sarr)
bmax = max(barr)
if smin < bmax:
	ans = r // smin * bmax + r % smin
else:
	ans = r
print(ans)


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


from sys import setcheckinterval, setrecursionlimit, stdout, stdin
setcheckinterval(1000)
setrecursionlimit(10 ** 6)
iin = lambda : int(stdin.readline())
lin = lambda : list(map(int, stdin.readline().split()))
(n, m, r) = lin()
m = lin()
n = lin()
m1 = min(m)
n1 = max(n)
if n1 < m1:
	print(r)
else:
	ch = r // m1
	print(ch * n1 + r - ch * m1)


R = lambda : map(int, input().split())
(n, m, r) = R()
a = min(R())
b = max(R())
if a < b:
	k = r // a
	print(r - k * a + k * b)
else:
	print(r)


(n, m, cur) = [int(x) for x in input().split()]
b = min([int(x) for x in input().split()])
s = max([int(x) for x in input().split()])
if s < b:
	print(cur)
	quit()
num = cur // b
cur += num * (s - b)
print(cur)


(x, y, z) = map(int, input().split())
p = min(list(map(int, input().split())))
t = max(list(map(int, input().split())))
if p > t:
	print(z)
else:
	k = z // p
	z -= k * p
	print(k * t + z)


(n, m, r) = [int(x) for x in input().split()]
s = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
min = s[0]
max = b[0]
for x in range(1, n):
	if s[x] < min:
		min = s[x]
for x in range(1, m):
	if b[x] > max:
		max = b[x]
k = int(r / min)
total = r - k * min + k * max
if total > r:
	print(total)
else:
	print(r)


a = [int(x) for x in input().split()]
buy = [int(x) for x in input().split()]
sell = [int(x) for x in input().split()]
buy.sort()
sell.sort()
MinBuy = min(buy)
MaxSell = max(sell)
BeginBourles = a[2]
MaxBourles = 0
if MinBuy >= MaxSell:
	print(a[2])
	exit(0)
for k in range(0, len(buy)):
	if a[2] < buy[k]:
		break
	else:
		MaxBourles += a[2] // buy[k]
		a[2] %= buy[k]
print(MaxBourles * MaxSell + a[2])


import math
import heapq
(n, m, r) = map(int, input().split())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
if a[0] < b[-1]:
	s = r // a[0]
	r -= s * a[0]
	print(r + s * b[-1])
else:
	print(r)


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


(n, m, r) = map(int, input().split())
s = [int(x) for x in input().split()]
b = [int(y) for y in input().split()]
min1 = min(s)
max1 = max(b)
k = r // min1
rem = r - k * min1
sell = k * max1
total = sell + rem
if total > r:
	print(total)
else:
	print(r)


(_, _, money) = map(int, input().split())
buy_price_best = min(map(int, input().split()))
sell_price_best = max(map(int, input().split()))
if sell_price_best <= buy_price_best:
	print(money)
	exit(0)
stocks = money // buy_price_best
money -= stocks * buy_price_best
print(stocks * sell_price_best + money)


line1 = input().split()
n = int(line1[0])
m = int(line1[1])
r = int(line1[2])
min_buy = None
max_sell = None
line2 = input().split()
line3 = input().split()
for i in range(n):
	num = int(line2[i])
	if not min_buy:
		min_buy = num
	elif min_buy > num:
		min_buy = num
for j in range(m):
	num = int(line3[j])
	if not max_sell:
		max_sell = num
	elif max_sell < num:
		max_sell = num
if min_buy < max_sell:
	value = r % min_buy + r // min_buy * max_sell
else:
	value = r
print(value)


(n, m, r) = [int(s) for s in input().split()]
ns = [int(s) for s in input().split()]
ms = [int(s) for s in input().split()]
nMin = sorted(ns)[0]
mMax = sorted(ms)[m - 1]
if nMin >= mMax:
	print(r)
else:
	bought = int(r / nMin)
	print(r - bought * nMin + mMax * bought)


(n, m, r) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
if min(a) >= max(b):
	print(r)
else:
	c = r // min(a)
	d = r % min(a)
	e = max(b) * c
	print(e + d)


(n, m, r) = map(int, input().split())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
buymin = min(arr1)
sellmax = max(arr2)
if buymin >= sellmax:
	print(r)
else:
	ans = r % buymin + r // buymin * sellmax
	print(ans)


(n, m, r) = map(int, input().split())
ls = list(map(int, input().split()))
ts = list(map(int, input().split()))
v = int(r / min(ls))
c = v * max(ts)
c = c + (r - v * min(ls))
if c > r:
	print(c)
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) = map(int, input().split())
s = list(map(int, input().split()))
b = list(map(int, input().split()))
k1 = r // min(s)
k2 = r - k1 * min(s)
k3 = k1 * max(b)
k3 = k3 + k2
if k3 > r:
	print(k3)
else:
	print(r)


(n, m, r) = map(int, input().split())
l1 = min(map(int, input().split()))
l2 = max(map(int, input().split()))
if l2 <= l1:
	print(r)
else:
	w = r // l1
	e = r % l1
	w = l2 * w
	print(w + e)


a = int(input().split()[2])
s = input().split()
d = input().split()
k = []
l = []
for i in s:
	k.append(int(i))
for i in d:
	l.append(int(i))
m = min(k)
money = a % m
s = a // m
money += s * max(l)
print(max(money, a))


(a, b, r) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
print(r // min(a) * max([min(a)] + b) + r % min(a))


m = list(map(int, input().split()))
b = list(map(int, input().split()))
s = list(map(int, input().split()))
money = m[-1]
min_price = min(b)
max_price = max(s)
money_left = 0
shares = 0
if money >= min_price:
	for i in range(money):
		if money % min_price == 0:
			shares = int(money / min_price)
			break
		else:
			money -= 1
			money_left += 1
profit = shares * max_price + money_left
if profit > m[-1]:
	print(profit)
else:
	print(m[-1])


(n, m, r) = list(map(int, input().split()))
a = list(map(int, input().rstrip().split()))
b = list(map(int, input().rstrip().split()))
y = min(a)
p = max(b)
if y > r:
	print(r)
elif y > p:
	print(r)
else:
	print(r // y * p + r % y)


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


line_one = list(map(int, input().split()))
line_two = list(map(int, input().split()))
line_three = list(map(int, input().split()))
r = line_one[2]
min_buy_price = min(line_two)
max_sell_price = max(line_three)
if max_sell_price > min_buy_price:
	exchange = r % min_buy_price
	price = int(r / min_buy_price) * max_sell_price
	print(exchange + price)
else:
	print(r)


(n, m, r) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
a.sort()
b.sort()
if min(a) >= max(b):
	print(r)
	exit()
else:
	buy = r // min(a) * min(a)
	sell = buy // min(a) * max(b)
	print(r + sell - buy)


import math
from decimal import Decimal

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def dva():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)
(n, m, r) = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
a = min(a)
b = max(b)
kp = r // a
if b - a <= 0:
	print(r)
else:
	r += (b - a) * kp
	print(r)


(n, m, r) = map(int, input().split())
s = map(int, input().split())
b = map(int, input().split())
p1 = min(s)
p2 = max(b)
if p1 < p2:
	(q, r) = divmod(r, p1)
	r += q * p2
print(r)


def strtoint(n, list):
	for i in range(n):
		list[i] = int(list[i])
n = input().split()
strtoint(3, n)
buin = input().split()
strtoint(n[0], buin)
buout = input().split()
strtoint(n[1], buout)
buin.sort()
buout.sort(reverse=True)
if buin[0] > buout[0]:
	print(n[2])
	exit(0)
else:
	print(n[2] + int(n[2] / buin[0]) * (buout[0] - buin[0]))


(n, m, r) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
mina = min(a)
maxb = max(b)
i = r % mina + r // mina * maxb
if i > r:
	print(i)
else:
	print(r)


inp = input().split(' ')
n = int(inp[0])
m = int(inp[1])
r = int(inp[2])
b = list(map(int, input().split(' ')))
s = list(map(int, input().split(' ')))
m_b = min(b)
m_s = max(s)
if m_s <= m_b:
	print(r)
else:
	buy = int(r / m_b)
	rem = r - buy * m_b
	sold = buy * m_s
	print(sold + rem)


(n, m, r) = map(int, input().split())
buy_price = min([*map(int, input().split())])
sell_price = max([*map(int, input().split())])
my_money = r
units_bought = r // buy_price
r -= units_bought * buy_price
r += sell_price * units_bought
print(max(r, my_money))


inp = lambda : map(int, input().split())
(n, m, r) = inp()
(x, y) = (min(inp()), max(inp()))
sold = r // x * y
how = r - r // x * x
print(max(r, sold + how))


(n, m, r) = list(map(int, input().split()))
ns = list(map(int, input().split()))
ms = list(map(int, input().split()))
best_buy = min(ns)
best_sell = max(ms)
num_buy = r // best_buy
have = r - num_buy * best_buy
total = best_sell * num_buy + have
if total < r:
	print(r)
else:
	print(total)


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


(n, m, rr) = input().split()
mor = list(map(int, input().split()))
eve = list(map(int, input().split()))
mi = min(mor)
ma = max(eve)
r = int(rr)
if mi > ma:
	print(r)
else:
	ans = r % mi
	buy = r // mi
	sell = buy * ma
	print(sell + ans)


import bisect
import math
import sys
from collections import deque

def main():
	(n, m, r) = map(int, input().split())
	b = list(map(int, input().split()))
	s = list(map(int, input().split()))
	buy = min(b)
	sell = max(s)
	print(r if sell <= buy else r % buy + r // buy * sell)
main()


[n, m, r] = [int(x) for x in input().split()]
N = [int(x) for x in input().split()]
M = [int(x) for x in input().split()]
print(max(r, max(M) * (r // min(N)) + r % min(N)))


(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_m = min(s)
b_m = max(b)
print(max(r, r // s_m * b_m + r % s_m))


(n, m, r) = map(int, input().split())
s = list(map(int, input().split()))
b = list(map(int, input().split()))
s = sorted(s)
b = sorted(b)
if s[0] > b[-1]:
	print(r)
else:
	shares = r // s[0]
	r_new = r % s[0]
	print(r_new + shares * b[-1])


(n, m, r) = map(int, input().split(' '))
b = list(map(int, input().split(' ')))
s = list(map(int, input().split(' ')))
mini = min(b)
bought = r // mini
total = r - bought * mini
maxi = max(s)
total += maxi * bought
print(max(total, r))


(n, m, r) = [int(i) for i in input().split()]
pok = [int(i) for i in input().split()]
pr = [int(i) for i in input().split()]
pk_m = min(pok)
p_m = max(pr)
ck = r + 1
c = r // pk_m
r = r % pk_m
for j in range(c):
	r += p_m
print(max(ck - 1, r))


(n, m, r) = [int(x) for x in input().split(' ')]
s = [int(x) for x in input().split(' ')]
b = [int(x) for x in input().split(' ')]
min_s = min(s)
max_b = max(b)
if max_b > min_s:
	print(r // min_s * max_b + r % min_s)
else:
	print(r)


nmr = list(map(int, input().split()))
s = list(map(int, input().split()))
b = list(map(int, input().split()))
stocks = 0
minS = 1001
maxB = 0
for k in range(nmr[0]):
	minS = min(minS, s[k])
for k in range(nmr[1]):
	maxB = max(maxB, b[k])
if minS < maxB:
	stocks = nmr[2] // minS
	nmr[2] -= stocks * minS
	nmr[2] += stocks * maxB
print(nmr[2])


(n, m, r) = map(int, input().strip().split())
arr = list(map(int, input().strip().split()))
brr = list(map(int, input().strip().split()))
a = min(arr)
b = max(brr)
if a >= b:
	print(r)
else:
	x = r % a
	print(x + r // a * b)


def main():
	st = input().split(' ')
	n = int(st[0])
	m = int(st[1])
	r = int(st[2])
	bs = input().split(' ')
	for i in range(n):
		bs[i] = int(bs[i])
	ss = input().split(' ')
	for i in range(m):
		ss[i] = int(ss[i])
	S = max(ss)
	B = min(bs)
	if B >= S:
		print(str(r))
	else:
		num_shares = int(r / B)
		val = r + (S - B) * num_shares
		print(str(val))
main()


a = input().split()
for i in range(len(a)):
	a[i] = int(a[i])
s = input().split()
for i in range(a[0]):
	s[i] = int(s[i])
b = input().split()
for i in range(a[1]):
	b[i] = int(b[i])
max = a[2]
for i in s:
	for j in b:
		if int(a[2] / i) * j + a[2] - int(a[2] / i) * i > max:
			max = int(a[2] / i) * j + a[2] - int(a[2] / i) * i
print(max)


(m, n, r) = map(int, input().split())
morning = list(map(int, input().split()))
evening = list(map(int, input().split()))
min = min(morning)
max = max(evening)
if min < max:
	share = r // min
	r %= min
	r += max * share
print(r)


(n, m, r) = map(int, input().split())
n_s = min(list(map(int, input().split())))
m_s = max(list(map(int, input().split())))
print(r % n_s + m_s * (r // n_s) if m_s > n_s else r)


(n, m, r) = map(int, input().split())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
a = min(l1)
b = max(l2)
if a < b:
	q = r // min(l1)
	w = q * b
	print(r - a * q + w)
elif a >= b:
	print(r)


temp = input().split(' ')
n = int(temp[0])
m = int(temp[1])
byr = int(temp[2])
s = input().split(' ')
b = input().split(' ')
s = [int(item) for item in s]
b = [int(item) for item in b]
s.sort()
b.sort(reverse=True)
max_tickets = int(byr / s[0])
byed = []
for tickets in range(max_tickets + 1):
	byr_now = byr
	byr_now -= int(s[0] * tickets)
	byr_now += b[0] * tickets
	byed.append(byr_now)
byed.sort(reverse=True)
print(byed[0])


import math
read = lambda : map(int, input().split())

def codeforce1150A():
	(n, m, r) = read()
	mor = min(list(read()))
	even = max(list(read()))
	if mor < even:
		pro = r // mor * (even - mor)
		print(r + pro)
	else:
		print(r)
codeforce1150A()


bouries = int(input().split(' ')[2])
buys = [int(x) for x in input().split(' ')]
sells = [int(x) for x in input().split(' ')]
buys.sort()
sells.sort(reverse=True)
sell = bouries // buys[0] * sells[0] + bouries % buys[0]
if sell > bouries:
	print(sell)
else:
	print(bouries)


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


a = input().split()
(n, m, r) = (int(a[0]), int(a[1]), int(a[2]))
s = 1000
b = 1
a = input().split()
for i in range(n):
	if int(a[i]) < s:
		s = int(a[i])
a = input().split()
for i in range(m):
	if int(a[i]) > b:
		b = int(a[i])
if s < b:
	n = int(r / s)
	r = r % s + n * b
print(r)


from sys import stdin
sys_input = stdin.readline

def si():
	return sys_input().rstrip()

def ii():
	return int(si())

def sti():
	return si().split()

def iti():
	return map(int, sti())

def sli():
	return list(si())

def ili():
	return list(iti())

def main():
	min_s = min(S)
	max_b = max(B)
	if min_s >= max_b:
		print(R)
		return
	s = R // min_s
	result = max_b * s + (R - min_s * s)
	print(result)
	return
(N, M, R) = iti()
S = ili()
B = ili()
main()


(n, m, r) = map(int, input().split())
s = list(map(int, input().split()))
d = list(map(int, input().split()))
a = min(s)
b = max(d)
if b - a > 0:
	print(r + r // a * (b - a))
else:
	print(r)


(n, m, r) = map(int, input().split())
buy_shares = list(map(int, input().split()))
sell_shares = list(map(int, input().split()))
a = r // min(buy_shares)
buy = min(buy_shares) * a
if max(sell_shares) > min(buy_shares):
	print(a * max(sell_shares) + r % min(buy_shares))
else:
	print(r)


p = input().rstrip().split(' ')
n = int(p[0])
m = int(p[1])
b = int(p[2])
Q = b
q = input().rstrip().split(' ')
r = input().rstrip().split(' ')
q.sort(key=int)
r.sort(key=int, reverse=True)
t = b // int(q[0])
b = b - t * int(q[0])
b = b + t * int(r[0])
print(max(b, Q))


ln = [int(i) for i in input().split(' ')]
n = ln[0]
m = ln[1]
r = ln[2]
a = [int(i) for i in input().split(' ')]
b = [int(i) for i in input().split(' ')]
if min(a) > max(b):
	print(r)
else:
	print(r // min(a) * max(b) + r % min(a))


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


(n, m, r) = map(int, input().split())
b = list(map(int, input().split()))
c = list(map(int, input().split()))
k = min(b)
p = max(c)
if p > k:
	d = r % k
	print(p * (r // k) + d)
else:
	print(r)


(n, m, a) = map(int, input().split())
l1 = [int(x) for x in input().split()]
l2 = [int(x) for x in input().split()]
b = a
share_bought = b // min(l1)
share_spend = share_bought * max(l2)
total_profit = share_spend + b % min(l1)
if total_profit > a:
	print(total_profit)
else:
	print(a)


(n, k, b) = map(int, input().split())
l = list(map(int, input().split()))
l1 = list(map(int, input().split()))
l.sort()
l1.sort()
x1 = b // l[0]
rem = b - x1 * l[0]
pro = l1[len(l1) - 1] * x1 + rem
if pro > b:
	print(pro)
else:
	print(b)


(n, m, b) = map(int, input().split())
l = list(map(int, input().split()))
h = list(map(int, input().split()))
c = b - min(l) * (b // min(l)) + max(h) * (b // min(l))
if c > b:
	print(c)
else:
	print(b)


(n, m, r) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
sell = list(map(int, input().split()))
mx = max(sell)
cost = r
for x in arr:
	if x < mx and r > 0:
		t = r // x
		r = r - t * x
		cost += t * (mx - x)
print(cost)


(n, m, r) = map(int, input().split())
s = list(map(int, input().split()))
b = list(map(int, input().split()))
m1 = min(s)
m2 = max(b)
if m1 < m2:
	u = r // m1
	r = r - u * m1
	p = u * m2
	r = r + p
	print(r)
else:
	print(r)


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


(n, m, r) = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
s = [int(x) for x in input().split()]
mn = min(b)
mx = max(s)
if mx > mn and r >= mn:
	(q, r) = divmod(r, mn)
	r += q * mx
print(r)


(n, m, r) = list(map(int, input().strip().split()))
si = list(map(int, input().strip().split()))
bi = list(map(int, input().strip().split()))
if min(si) < max(bi):
	shares = r // min(si)
	r = r - min(si) * shares
	r = r + max(bi) * shares
print(r)


(n, m, r) = map(int, input().split())
b = list(map(int, input().split()))
c = list(map(int, input().split()))
sum2 = 0
sum1 = 0
s = 0
k = 0
val = 0
ans = 0
j = 0
div = 0
j = max(n, m)
s = min(b)
k = max(c)
if s <= k:
	div = r // s
	val = k - s
	ans = r + div * val
	print(ans)
else:
	print(r)


def main():
	(n, m, r) = map(int, input().split())
	s = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	if min(s) < max(b):
		print(r % min(s) + r // min(s) * max(b))
	else:
		print(r)
main()


from sys import stdin
from collections import defaultdict as dd
import math

def Main():
	(n, m, r) = map(int, stdin.readline().split())
	s = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	if min(s) >= max(b):
		print(r)
	else:
		a = r // min(s)
		print(r + (max(b) - min(s)) * a)
Main()


(n, m, b) = map(int, input().split())
sn = [*map(int, input().split())]
sm = [*map(int, input().split())]
sn.sort()
sm.sort()
if sn[0] < sm[-1]:
	no_share = b // sn[0]
	print(no_share * sm[-1] + b % sn[0])
else:
	print(b)


(n, m, r) = map(int, input().split())
s = list(map(int, input().split()))
b = list(map(int, input().split()))
s.sort()
b.sort(reverse=True)
rr = r
share = 0
i = 0
while r > 0 and i < n:
	share += r // s[i]
	r -= r // s[i] * s[i]
	i += 1
i = 0
ans = r + b[0] * share
print(max(ans, rr))


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


(M, N, X) = map(int, input().split())
L1 = list(map(int, input().split()))
L2 = list(map(int, input().split()))
count = int(X / min(L1))
ans = X % min(L1)
ans += max(L2) * count
if ans < X:
	ans = X
print(ans)


(n, m, d) = map(int, input().split())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
k = min(arr1)
j = max(arr2)
if k >= j:
	print(d)
else:
	print(d % k + d // k * j)


(n, m, r) = map(int, input().split())
lb = list(map(int, input().split()))
ls = list(map(int, input().split()))
mn = min(lb)
x = r // mn
mx = max(ls)
if mx > mn:
	r += x * (mx - mn)
print(r)


line = tuple(map(int, input().split(' ')))
(morningSharesCount, eveningSharesCount, initMoney) = line
morningShares = list(map(int, input().split(' ')))
eveningShares = list(map(int, input().split(' ')))
minMorningShare = min(morningShares)
maxEveningShare = max(eveningShares)
money = initMoney
sharesCount = money // minMorningShare
remaining = money - sharesCount * minMorningShare
money = sharesCount * maxEveningShare + remaining
print(max(money, initMoney))


from sys import *
from math import *
(n, m, r) = map(int, stdin.readline().split())
a = list(map(int, stdin.readline().split()))
b = list(map(int, stdin.readline().split()))
if min(a) > max(b):
	print(r)
else:
	x = r // min(a)
	ans = r % min(a)
	y = x * max(b)
	ans += y
	print(ans)


(X, Min, Max) = (list(map(int, input().split())), min(map(int, input().split())), max(map(int, input().split())))
print(X[2] // Min * Max + X[2] % Min if Min < Max else X[2])


(n, m, r) = map(int, input().strip().split())
buy = sorted([int(i) for i in input().strip().split()])
sell = sorted([int(i) for i in input().strip().split()], reverse=True)
to_buy = buy[0]
result = r // to_buy
remain = r - result * to_buy
remain += sell[0] * result
if remain > r:
	print(remain)
else:
	print(r)


(n, m, r) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = min(a)
y = max(b)
ans = r
if y > x:
	p = r // x
	ans += p * y - p * x
print(ans, end='')


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

def si():
	return input()

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

def li():
	return list(mi())
(n, m, l) = mi()
a = li()
b = li()
x = min(a)
n1 = l // x
l1 = l % x
y = max(b)
l1 += n1 * y
print(max(l, l1))


(n, m, r) = map(int, input().split())
srr = [int(x) for x in input().split()]
brr = [int(x) for x in input().split()]
mns = min(srr)
mxb = max(brr)
if mns >= mxb:
	print(r)
else:
	x = r // mns
	r -= mns * x
	r += mxb * x
	print(r)


(n, m, k) = map(int, input().split())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
s = min(l1)
d = k // s
c = k % s
b = max(l2)
c += d * b
if c > k:
	print(c)
else:
	print(k)


(n, m, r) = map(int, input().split())
srr = [int(x) for x in input().split()]
brr = [int(x) for x in input().split()]
(x, y) = (min(srr), max(brr))
if x < y:
	answer = r % x
	answer += r // x * y
	print(answer)
else:
	print(r)


R = lambda : map(int, input().split())
(n, m, r) = R()
(minn, maxn) = (min(R()), max(R()))
print(r // minn * maxn + r % minn if maxn > minn else r)


(n, m, r) = map(int, input().split())
s = list(map(int, input().split()))
b = list(map(int, input().split()))
bp = min(s)
bpi = s.index(bp)
sp = max(b)
spi = b.index(sp)
buy = 0
sell = 0
cur = 0
while cur <= r:
	cur += bp
	buy += 1
if cur > r:
	cur -= bp
	buy -= 1
if bp < sp:
	sell = sp * buy
	print(sell + (r - cur))
else:
	print(r)


(n, m, r) = map(int, input().split())
buy = list(map(int, input().split()))
sell = list(map(int, input().split()))
h1 = min(buy)
k1 = max(sell)
stocksby = r // h1
leftmoney = r - h1 * stocksby
gotmoney = k1 * stocksby
print(max(r, gotmoney + leftmoney))


(n, m, r) = map(int, input().split(' '))
s1 = list(map(int, input().split(' ')))
s2 = list(map(int, input().split(' ')))
if max(s2) > min(s1):
	min_s = min(s1)
	q = r // min_s
	r = r - min_s * q
	r += max(s2) * q
	print(r)
else:
	print(r)


(n, m, r) = map(int, input().split())
s = list(map(int, input().split()))
b = list(map(int, input().split()))
minv = min(s)
maxv = max(b)
temp = 0
if minv < maxv:
	temp = r // minv * maxv
	r = r % minv
print(temp + r)


(n, m, r) = list(map(int, input().split()))
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
rini = r
cost1 = min(arr1)
resto = r % cost1
r -= resto
r = r // cost1
print(max(r * max(arr2) + resto, rini))


(n, m, r) = map(int, input().split())
buy = list(map(int, input().split()))
sell = list(map(int, input().split()))
x = r // min(buy)
left = r - x * min(buy)
y = max(sell) * x
if y + left > r:
	print(y + left)
else:
	print(r)


(n, m, r) = map(int, input().split())
b = sorted(list(map(int, input().split())))[0]
s = sorted(list(map(int, input().split())))[-1]
(p, q) = divmod(r, b)
print(p * s + q if p * s + q > r else r)


from sys import stdin

def main():
	(N, M, R) = map(int, input().split())
	S = map(int, input().split())
	B = map(int, input().split())
	(stock, bourles) = divmod(R, min(S))
	bourles += stock * max(B)
	print(max(bourles, R))
input = lambda : stdin.readline()
main()


(N, M, R) = map(int, input().split())
b = min(map(int, input().split()))
s = max(map(int, input().split()))
a = R % b + R // b * s
print(max(R, a))


(m, n, b) = map(int, input().split())
k = input().split()
k1 = input().split()
k = [int(i) for i in k]
k1 = [int(i) for i in k1]
if min(k) >= max(k1):
	print(b)
else:
	j = b // min(k)
	b -= j * min(k)
	b += j * max(k1)
	print(b)


(n, m, r) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
buy = r // min(a)
remain = r - buy * min(a)
ans = remain + buy * max(b)
print(max(ans, r))


(n, m, r) = map(int, input().split())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
count = r // min(arr1)
num = r - count * min(arr1)
ans = count * max(arr2) + num
print(ans if ans > r else r)


nmr = input().split()
n = int(nmr[0])
m = int(nmr[1])
r = int(nmr[2])
C = list(map(int, input().split()))
S = list(map(int, input().split()))
x = min(C)
y = max(S)
if y <= x:
	print(r)
else:
	n = r // x
	rem = r % x
	r = rem + n * y
	print(r)


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


first_line = input()
second_line = input()
third_line = input()
first_line_int = first_line.split()
s = second_line.split()
b = third_line.split()
r = int(first_line_int[2])

def find_buy_min():
	min = int(s[0])
	for num in s:
		if min >= int(num):
			min = int(num)
	return min

def find_sell_max():
	max = int(b[0])
	for num in b:
		if max <= int(num):
			max = int(num)
	return max

def maximum_bourles():
	num_buy = r // find_buy_min()
	remain = r - num_buy * find_buy_min() + num_buy * find_sell_max()
	if remain > r:
		print(remain)
	else:
		print(r)
maximum_bourles()


a = input().split()
n = int(a[0])
m = int(a[1])
r = int(a[2])
s = []
for i in input().split():
	s += [int(i)]
colvo_p = r // int(min(s))
b = []
for i in input().split():
	b += [int(i)]
colvo_pr = colvo_p * int(max(b))
if colvo_pr + (r - colvo_p * int(min(s))) >= r:
	print(colvo_pr + (r - colvo_p * int(min(s))))
else:
	print(r)


(n, m, r) = map(int, input().split())
s = map(int, input().split())
b = map(int, input().split())
ms = min(s)
mb = max(b)
if ms < mb:
	shares = int(r / ms)
	left = r % ms
	res = shares * mb
	r = res + left
print(r)


(n, m, r) = map(int, input().split())
l = list(map(int, input().split()))
d = list(map(int, input().split()))
x = min(l)
s = r // x
mm = s * max(d)
p = mm + r % x
if r >= p:
	print(r)
else:
	print(p)


(n, m, r) = map(int, input().split())
s = input().split()
b = input().split()
for i in range(n):
	s[i] = int(s[i])
for i in range(m):
	b[i] = int(b[i])
s.sort()
b.sort(reverse=True)
if b[0] <= s[0]:
	print(r)
else:
	ans = 0
	i = 0
	while r > 0 and i < n:
		ans += r // s[i] * b[0]
		r = r % s[i]
		i += 1
	print(ans + r)


(n, m, r) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
hmc = r // min(a)
re = r % min(a)
hme = hmc * max(b)
if hme + re >= r:
	print(hme + re)
else:
	print(r)


def myfunc(l1):
	return l1[-1]

def solution(l1, l2, l3):
	(n, m, r) = (l1[0], l1[1], l1[2])
	l2.sort()
	l3.sort()
	l3.reverse()
	i = 0
	ans = r
	while r >= 0 and i < len(l2) and (l3[0] - l2[i] > 0):
		if r >= l2[i]:
			r -= l2[i]
			ans += l3[0] - l2[i]
		else:
			i += 1
	return ans

def answer():
	l1 = [int(x) for x in input().split()]
	l2 = [int(x) for x in input().split()]
	l3 = [int(x) for x in input().split()]
	print(solution(l1, l2, l3))
answer()


intin = lambda : map(int, input().split())
Ain = lambda : list(map(int, input().split()))
(n, m, r) = intin()
a = Ain()
b = Ain()
maxb = 0
mina = 100000000000000
for i in range(m):
	maxb = max(maxb, b[i])
for i in range(n):
	mina = min(mina, a[i])
num = r // mina
sol = num * (maxb - mina)
print(max(sol, 0) + r)


money = int(input().split()[-1])
best_price = min(map(int, input().split()))
best_sell = max(map(int, input().split()))

def calc_profit():
	if best_price >= best_sell:
		return money
	actions = money // best_price
	remaining = money % best_price
	result = actions * best_sell + remaining
	return result
print(calc_profit())


(n, m, r) = map(int, input().split())
ai = list(map(int, input().split()))
bi = list(map(int, input().split()))
if min(ai) >= max(bi):
	print(r)
else:
	a = r // min(ai)
	print(a * max(bi) + (r - a * min(ai)))


def solve():
	mini = min(s)
	x = r // mini
	return max(x * max(b) + (r - x * mini), r)

def main():
	global n, m, r, s, b
	(n, m, r) = list(map(int, input().split()))
	s = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(solve())
main()


(n, m, r) = map(int, input().split())
count = 0
sp = min(list(map(int, input().split())))
w = max(list(map(int, input().split())))
print(max(r, r // sp * w + r % sp))


(n, m, r) = map(int, input().split())
B = [*map(int, input().split())]
S = [*map(int, input().split())]
B.sort()
S.sort(reverse=True)
(org, p) = (r, 0)
for i in range(min(len(B), len(S))):
	if S[i] > B[i]:
		while r >= B[i]:
			p += S[i] - B[i]
			r -= B[i]
print(org + p)


def main():
	s = [int(x) for x in input().split()]
	r = s[2]
	buy = min([int(x) for x in input().split()])
	sell = max([int(x) for x in input().split()])
	morning = r // buy
	evening = morning * sell
	if sell > buy:
		ans = evening + r % buy
		print(ans)
	else:
		print(r)
main()


(n, m, r) = [int(x) for x in str(input()).split()]
N = [int(x) for x in str(input()).split()]
M = [int(x) for x in str(input()).split()]
nMin = min(N)
mMax = max(M)
numShares = int(r / nMin)
profit = numShares * mMax
profit += r % nMin
if profit > r:
	print(profit)
else:
	print(r)


(n, m, k) = map(int, input().split())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
x = []
K = min(l1)
D = max(l2)
if D <= K:
	print(k)
	exit()
ans = k // K * D
k = k - k // K * K
print(ans + k)


(n, m, r) = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
mn = min(a)
mx = max(b)
if mn < mx:
	cnt = r // mn
	r = r % mn
	r += cnt * mx
print(r)


first_line_components = input().split(' ')
s = [int(i) for i in input().split(' ')]
b = [int(i) for i in input().split(' ')]
r = int(first_line_components[2])
min_buy = min(s)
max_sell = max(b)
balance = r % min_buy
balance += r // min_buy * max_sell
result = max([balance, r])
print(result)


def main():
	(n, m, r) = list(map(int, input().strip().split()))
	s = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	min_s = min(s)
	max_b = max(b)
	if max_b <= min_s:
		print(r)
		return
	k = r // min_s
	print(r + k * (max_b - min_s))
main()


(n, m, r) = map(int, input().split())
a = list(map(int, input().split()))
t = list(map(int, input().split()))
b = min(a)
no = r // b
co = no * b
w = max(t)
se = w * no
sa = se - co
if sa > 0:
	print(r + sa)
else:
	print(r)


(a, b, c) = map(int, input().split())
t = 0
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = min(x)
t = c % z
print(max(c, max(y) * (c // z) + t))


I = lambda : map(int, input().split())
(_, _, r) = I()
bp = min(I())
sp = max(I())
ba = r // bp
rem = r - ba * bp
print(sp * ba + rem if bp < sp else r)


(morning, evening, roubles) = map(int, input().split())
buy = list(map(int, input().split()))
sell = list(map(int, input().split()))
mb = min(buy)
b = roubles // mb
ms = max(sell)
s = b * ms
s += roubles - mb * b
if s > roubles:
	print(s)
else:
	print(roubles)


def get_input_data():
	(ways_to_buy, ways_to_sell, start_capital) = list(map(int, input().split(' ')))
	buy_shares = list(map(int, input().split(' ')))
	sell_shares = list(map(int, input().split(' ')))
	return (buy_shares, sell_shares, start_capital)

def best_strategy_to_buy_and_sell_shares(buy_shares, sell_shares, start_capital):
	min_buy = min(buy_shares)
	max_sell = max(sell_shares)
	if min_buy >= max_sell:
		return start_capital
	else:
		num_of_buy_shares = start_capital // min_buy
		remaining_capital = start_capital % min_buy
		end_of_day_capital = remaining_capital + max_sell * num_of_buy_shares
	return end_of_day_capital
(buy_shares, sell_shares, start_capital) = get_input_data()
end_of_day_capital = best_strategy_to_buy_and_sell_shares(buy_shares, sell_shares, start_capital)
print(end_of_day_capital)