Vasya often uses public transport. The transport in the city is of two types: trolleys and buses. The city has n buses and m trolleys, the buses are numbered by integers from 1 to n, the trolleys are numbered by integers from 1 to m.

Public transport is not free. There are 4 types of tickets:   A ticket for one ride on some bus or trolley. It costs c_1 burles;  A ticket for an unlimited number of rides on some bus or on some trolley. It costs c_2 burles;  A ticket for an unlimited number of rides on all buses or all trolleys. It costs c_3 burles;  A ticket for an unlimited number of rides on all buses and trolleys. It costs c_4 burles. 

Vasya knows for sure the number of rides he is going to make and the transport he is going to use. He asked you for help to find the minimum sum of burles he will have to spend on the tickets.


-----Input-----

The first line contains four integers c_1, c_2, c_3, c_4 (1 ≤ c_1, c_2, c_3, c_4 ≤ 1000) — the costs of the tickets.

The second line contains two integers n and m (1 ≤ n, m ≤ 1000) — the number of buses and trolleys Vasya is going to use.

The third line contains n integers a_{i} (0 ≤ a_{i} ≤ 1000) — the number of times Vasya is going to use the bus number i.

The fourth line contains m integers b_{i} (0 ≤ b_{i} ≤ 1000) — the number of times Vasya is going to use the trolley number i.


-----Output-----

Print a single number — the minimum sum of burles Vasya will have to spend on the tickets.


-----Examples-----
Input
1 3 7 19
2 3
2 5
4 4 4

Output
12

Input
4 3 2 1
1 3
798
1 2 3

Output
1

Input
100 100 8 100
3 5
7 94 12
100 1 47 0 42

Output
16



-----Note-----

In the first sample the profitable strategy is to buy two tickets of the first type (for the first bus), one ticket of the second type (for the second bus) and one ticket of the third type (for all trolleys). It totals to (2·1) + 3 + 7 = 12 burles.

In the second sample the profitable strategy is to buy one ticket of the fourth type.

In the third sample the profitable strategy is to buy two tickets of the third type: for all buses and for all trolleys.

Source: codeforces | Difficulty: EASY
Tags: Implementation

Greedy algorithms


Solutions:
(c1, c2, c3, c4) = map(int, input().split())
(n, m) = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
ans1 = 0
ans2 = 0
for i in a:
	ans1 += min(c1 * i, c2)
ans1 = min(ans1, c3)
for i in b:
	ans2 += min(c1 * i, c2)
ans2 = min(ans2, c3)
ans = min(ans1 + ans2, c4)
print(ans)


from math import floor
(c1, c2, c3, c4) = list(map(int, input().split()))
(n, m) = list(map(int, input().split()))
bus = [int(x) for x in input().split()]
trol = [int(x) for x in input().split()]
thres = floor(c2 / c1)
bus_res = 0
for v in bus:
	if v > thres:
		bus_res += c2
	else:
		bus_res += v * c1
bus = min(c3, bus_res)
trol_res = 0
for v in trol:
	if v > thres:
		trol_res += c2
	else:
		trol_res += v * c1
trol = min(c3, trol_res)
print(min(bus + trol, c4))


c = [int(x) for x in input().split()]
(n, m) = (int(x) for x in input().split())
a = b = 0
for x in input().split():
	x = int(x)
	a += min(x * c[0], c[1])
for x in input().split():
	x = int(x)
	b += min(x * c[0], c[1])
print(min(c[3], min(c[2], a) + min(c[2], b)))


c = list(map(int, input().split()))
(n, m) = map(int, input().split())
b = list(map(int, input().split()))
t = list(map(int, input().split()))
d = 0
for x in b:
	if x * c[0] <= c[1]:
		d += x * c[0]
	else:
		d += c[1]
if d > c[2]:
	d = c[2]
f = 0
for x in t:
	if x * c[0] < c[1]:
		f += x * c[0]
	else:
		f += c[1]
if f > c[2]:
	f = c[2]
if d + f < c[3]:
	print(d + f)
else:
	print(c[3])


(c1, c2, c3, c4) = map(int, input().split())
(n, m) = map(int, input().split())
n1 = list(map(int, input().split()))
m1 = list(map(int, input().split()))
s1 = 0
r = []
for i in range(n):
	if n1[i] * c1 > c2:
		s1 = s1 + c2
	else:
		s1 = s1 + n1[i] * c1
r.append(s1 + c3)
s2 = 0
for i in range(m):
	if m1[i] * c1 > c2:
		s2 = s2 + c2
	else:
		s2 = s2 + m1[i] * c1
r.append(s2 + c3)
r.append(s1 + s2)
r.append(2 * c3)
r.append(c4)
print(min(r))


c = list(map(int, input().split()))
(n, m) = map(int, input().split())
(p, q) = (list(map(int, input().split())), list(map(int, input().split())))
print(min(c[3], min(c[2], sum((min(c[0] * i, c[1]) for i in p))) + min(c[2], sum((min(c[0] * i, c[1]) for i in q)))))


(ticket_one, ticket_two, ticket_three, ticket_four) = [int(x) for x in input().split()]
(buses, trolleys) = [int(x) for x in input().split()]
bus = [int(x) for x in input().split()]
trolley = [int(x) for x in input().split()]
minimum_bus_cost = 0
minimum_trolley_cost = 0
for b in bus:
	cost_ticket_one = b * ticket_one
	minimum_bus_cost += min(cost_ticket_one, ticket_two)
minimum_bus_cost = min(minimum_bus_cost, ticket_three)
for t in trolley:
	cost_ticket_one = t * ticket_one
	minimum_trolley_cost += min(cost_ticket_one, ticket_two)
minimum_trolley_cost = min(minimum_trolley_cost, ticket_three)
total = minimum_bus_cost + minimum_trolley_cost
best_value = min(total, ticket_four)
print(best_value)


import sys
(c1, c2, c3, c4) = map(int, sys.stdin.readline().split(' '))
(nbBuses, nbTrolleys) = map(int, sys.stdin.readline().split(' '))
buses = map(int, sys.stdin.readline().split(' '))
trolleys = map(int, sys.stdin.readline().split(' '))
minBusesCost = 0
for nbRide in buses:
	minBusesCost += min(c2, nbRide * c1)
minTrolleysCost = 0
for nbRide in trolleys:
	minTrolleysCost += min(c2, nbRide * c1)
minCost = min(c4, min(c3, minBusesCost) + min(c3, minTrolleysCost))
print(minCost)


(c1, c2, c3, c4) = map(int, input().split())
(n, m) = map(int, input().split())
b = list(map(int, input().split()))
t = list(map(int, input().split()))
a = 0
for i in range(n):
	a += min(c1 * b[i], c2)
ans = min(a, c3)
b = 0
for i in range(m):
	b += min(c1 * t[i], c2)
ans += min(b, c3)
print(min(ans, c4))


(a, b, c, d) = map(int, input().split())
(bu, tr) = map(int, input().split())
bl = list(map(int, input().split()))
tl = list(map(int, input().split()))
t = 0
to = 0
for x in bl:
	if a * x > b:
		to += b
	else:
		to += a * x
if to >= c:
	to = c
p1 = to
to = 0
for x in tl:
	if a * x > b:
		to += b
	else:
		to += a * x
if to >= c:
	to = c
to += p1
if to > d:
	to = d
print(to)


(c1, c2, c3, c4) = list(map(int, input().split()))
(n, m) = list(map(int, input().split()))
bus = list(map(int, input().split()))
tro = list(map(int, input().split()))
(x1, x2, x3) = (0, 0, 0)
for item in bus:
	if item * c1 > c2:
		x1 += c2
	else:
		x1 += item * c1
for item in tro:
	if item * c1 > c2:
		x2 += c2
	else:
		x2 += item * c1
x3 = min(x1, c3) + min(x2, c3)
if c4 < x3:
	print(c4)
else:
	print(x3)


def __starting_point():
	arr = input().split(' ')
	c = []
	for a in arr:
		c.append(int(a))
	ans = min(c[3], 2 * c[2])
	arr = input().split(' ')
	n = int(arr[0])
	m = int(arr[1])
	an = []
	am = []
	arr = input().split(' ')
	for a in arr:
		an.append(int(a))
	arr = input().split(' ')
	for a in arr:
		am.append(int(a))
	ca = 0
	for a in an:
		if a * c[0] < c[1]:
			ca += a * c[0]
		else:
			ca += c[1]
	ca = min(ca, c[2])
	cb = 0
	for a in am:
		if a * c[0] < c[1]:
			cb += a * c[0]
		else:
			cb += c[1]
	cb = min(cb, c[2])
	ans = min(ans, ca + cb)
	print(ans)
__starting_point()


costs = input().split(' ')
costs = [int(x) for x in costs]
data = input().split(' ')
totalBuses = int(data[0])
totalTrolleys = int(data[1])
buses = input().split(' ')
trolleys = input().split(' ')
buses = [int(x) for x in buses]
trolleys = [int(x) for x in trolleys]
possibleCosts = [0, 0, 0, 0]
totalBusTravels = sum(buses)
totalTrolleysTravels = sum(trolleys)
cost = [0, 0]
for busCost in buses:
	if busCost * costs[0] > costs[1]:
		cost[0] += costs[1]
	else:
		cost[0] += busCost * costs[0]
if cost[0] > costs[2]:
	cost[0] = costs[2]
for trolleyCost in trolleys:
	if trolleyCost * costs[0] > costs[1]:
		cost[1] += costs[1]
	else:
		cost[1] += trolleyCost * costs[0]
if cost[1] > costs[2]:
	cost[1] = costs[2]
if cost[0] + cost[1] > costs[3]:
	print(costs[3])
else:
	print(cost[0] + cost[1])


c = list(map(int, input().split(' ')))
c1 = c[0]
c2 = c[1]
c3 = c[2]
c4 = c[3]
input()
busRides = list(map(int, input().split(' ')))
troRides = list(map(int, input().split(' ')))
busSum = 0
for rides in busRides:
	busSum += min(c2, rides * c1)
busMin = min(c3, busSum)
troSum = 0
for rides in troRides:
	troSum += min(c2, rides * c1)
troMin = min(c3, troSum)
print(min(c4, troMin + busMin))


(c1, c2, c3, c4) = map(int, input().split())
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
suma = sum((min(c1 * x, c2) for x in a))
sumb = sum((min(c1 * x, c2) for x in b))
print(min(min(suma, c3) + min(sumb, c3), c4))


(a, b, c, d) = map(int, input().split())
(n, m) = map(int, input().split())
t = list(map(int, input().split()))
h = list(map(int, input().split()))
v = []
w = []
for i in t:
	v.append(min(a * i, b))
for i in h:
	w.append(min(a * i, b))
t = min(c, sum(v))
h = min(c, sum(w))
print(min(d, t + h))


R = lambda : map(int, input().split())
(a1, a2, a3, a4) = R()
(n, m) = R()
b1 = list(map(lambda x: min(int(x) * a1, a2), input().split()))
b2 = list(map(lambda x: min(int(x) * a1, a2), input().split()))
print(min(min(sum(b1), a3) + min(sum(b2), a3), a4))


c = [int(x) for x in input().split()]
(n, m) = list(map(int, input().split()))
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
bu = min(c[2], sum((min(c[1], c[0] * ai) for ai in a)))
tr = min(c[2], sum((min(c[1], c[0] * bi) for bi in b)))
print(min(c[3], bu + tr))


import sys

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

def iinput():
	return int(input())

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

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
(c1, c2, c3, c4) = rinput()
(n, m) = rinput()
a = list(map(int, input().split()))
b = list(map(int, input().split()))
s = 0
for i in range(len(a)):
	s += min(c2, c1 * a[i])
s1 = min(c3, s)
l = 0
for i in range(len(b)):
	l += min(c2, c1 * b[i])
l1 = min(c3, l)
print(min(c4, s1 + l1))


import sys
import string
from collections import Counter, defaultdict
from math import fsum, sqrt, gcd, ceil, factorial
from operator import add
inf = float('inf')
flush = lambda : sys.stdout.flush
comb = lambda x, y: factorial(x) // factorial(y) // factorial(x - y)
ip = lambda : input()
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())
(a, b, c, d) = r()
(n, k) = r()
arr = rr()
brr = rr()
cost = 0
for i in range(n):
	cost += min(arr[i] * a, b)
cost = min(cost, c)
cost2 = 0
for i in range(k):
	cost2 += min(brr[i] * a, b)
cost2 = min(cost2, c)
print(min(cost + cost2, d))


(a, b, c, d) = map(int, input().split())
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
x = list(map(int, input().split()))
xx = 0
for i in range(n):
	u = min(a * l[i], b)
	xx = xx + u
xx = min(xx, c)
yy = 0
for i in range(m):
	u = min(a * x[i], b)
	yy = yy + u
yy = min(yy, c)
z = xx + yy
print(min(d, z))


(c1, c2, c3, c4) = map(int, input().split())
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
sum1 = 0
for i in range(n):
	sum1 += min(a[i] * c1, c2)
sum2 = 0
for i in range(m):
	sum2 += min(b[i] * c1, c2)
print(min(c4, 2 * c3, c3 + sum1, c3 + sum2, sum1 + sum2))


(c1, c2, c3, c4) = map(int, input().split())
(n, m) = map(int, input().split())
bus = list(map(int, input().split()))
p = c2 // c1
for idx in range(n):
	if bus[idx] > 0:
		if bus[idx] > p:
			bus[idx] = c2
		else:
			bus[idx] = bus[idx] * c1
b_total = min(sum(bus), c3)
trol = list(map(int, input().split()))
for idx in range(m):
	if trol[idx] > 0:
		if trol[idx] > p:
			trol[idx] = c2
		else:
			trol[idx] = trol[idx] * c1
t_total = min(sum(trol), c3)
print(min(b_total + t_total, c4))


x = input().split()
c1 = int(x[0])
c2 = int(x[1])
c3 = int(x[2])
c4 = int(x[3])
x = input().split()
n = int(x[0])
m = int(x[1])
a = []
b = []
p1 = []
p2 = []
x = input().split()
for i in range(n):
	tmp = int(x[i])
	a.append(tmp)
x = input().split()
for i in range(m):
	tmp = int(x[i])
	b.append(tmp)
for i in range(len(a)):
	p1.append(min(c2, c1 * a[i]))
for i in range(len(b)):
	p2.append(min(c2, c1 * b[i]))
Pa = min(sum(p1), c3)
Pb = min(sum(p2), c3)
P = min(Pa + Pb, c4)
print(P)


(a, b, c, d) = list(map(int, input().split()))
(n, m) = list(map(int, input().split()))
s = u = 0
p = list(map(int, input().split()))
q = list(map(int, input().split()))
for i in range(n):
	s = s + min(b, a * p[i])
for i in range(m):
	u = u + min(b, a * q[i])
print(min(d, min(s, c) + min(u, c)))


c = list(map(int, input().split()))
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
sa = sum(a) * c[0]
sb = sum(b) * c[0]
for i in a:
	sa = min(sa, sa - i * c[0] + c[1])
for i in b:
	sb = min(sb, sb - i * c[0] + c[1])
print(min(sa + sb, sa + c[2], sb + c[2], c[2] + c[2], c[3]))


(c1, c2, c3, c4) = map(int, input().split())
(n, m) = map(int, input().split())
B = list(map(int, input().split()))
T = list(map(int, input().split()))
if sum(B) == 0:
	C = 0
	for item in T:
		if item * c1 > c2:
			C += c2
		else:
			C += item * c1
	print(min((C, c4, c3)))
elif sum(T) == 0:
	C = 0
	for item in B:
		if item * c1 > c2:
			C += c2
		else:
			C += item * c1
	print(min((C, c4, c3)))
else:
	A = 0
	for item in T:
		if item * c1 > c2:
			A += c2
		else:
			A += item * c1
	Q = 0
	for item in B:
		if item * c1 > c2:
			Q += c2
		else:
			Q += item * c1
	print(min((A + Q, c3 + c3, c4, A + c3, Q + c3)))


(a, b, c, d) = input().split()
a = int(a)
b = int(b)
c = int(c)
d = int(d)
(busao, bonde) = input().split()
busao = int(busao)
bonde = int(bonde)
busvet = input().split()
bovet = input().split()
for x in range(busao):
	busvet[x] = int(busvet[x])
for x in range(bonde):
	bovet[x] = int(bovet[x])
x = 0
y = 0
for i in range(busao):
	x = x + min(busvet[i] * a, b)
for i in range(bonde):
	y = y + min(bovet[i] * a, b)
resultado = min(d, min(c, x) + min(c, y))
print(resultado)


(c1, c2, c3, c4) = map(int, input().split())
(n, m) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
ans = c4
ans1 = c3
ans2 = c3
s1 = sum(a)
s2 = sum(b)
k = 0
for i in range(n):
	k += min(c2, a[i] * c1)
ans1 = min(ans1, k)
k = 0
for i in range(m):
	k += min(c2, b[i] * c1)
ans2 = min(ans2, k)
print(min(ans1 + ans2, ans))


import sys
for line in sys.stdin:
	cost = 0
	(c1, c2, c3, c4) = [int(x) for x in line.split()]
	line = next(sys.stdin)
	(n, m) = [int(x) for x in line.split()]
	line = next(sys.stdin)
	a = [int(x) for x in line.split()]
	line = next(sys.stdin)
	b = [int(x) for x in line.split()]
	cost1 = 0
	for x in a:
		cost1 += min(x * c1, c2)
	cost1 = min(cost1, c3)
	cost2 = 0
	for x in b:
		cost2 += min(x * c1, c2)
	cost2 = min(cost2, c3)
	cost = min(c4, cost1 + cost2)
	print(cost)


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

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

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

def array():
	return [int(i) for i in input().split()]
(c1, c2, c3, c4) = value()
(b, t) = value()
bl = array()
tl = array()
(troll_bus, cost_bus) = (0, 0)
for i in bl:
	cost_bus += min(i * c1, c2)
cost_bus = min(cost_bus, c3)
for i in tl:
	troll_bus += min(i * c1, c2)
troll_bus = min(troll_bus, c3)
print(min(troll_bus + cost_bus, c4))


def inputi():
	a = input().split(' ')
	return [int(i) for i in a]
(c1, c2, c3, c4) = inputi()
(n, m) = inputi()
a = inputi()
b = inputi()
sumn = 0
summ = 0
for i in a:
	if c1 * i < c2:
		sumn = sumn + c1 * i
	else:
		sumn = sumn + c2
if sumn > c3:
	sumn = c3
for i in b:
	if c1 * i < c2:
		summ = summ + c1 * i
	else:
		summ = summ + c2
if summ > c3:
	summ = c3
if sumn + summ > c4:
	print(c4)
else:
	print(sumn + summ)


def p(f):
	r = 0
	for x in f:
		if x * a > b:
			r += b
		else:
			r += x * a
	return r
scan = lambda : map(int, input().split())
(a, b, c, d) = scan()
(n, m) = scan()
f = list(scan())
g = list(scan())
r1 = p(f)
if r1 > c:
	r1 = c
r2 = p(g)
if r2 > c:
	r2 = c
r = r1 + r2
if r > d:
	r = d
print(r)


def main():
	(c1, c2, c3, c4) = list(map(int, input().split()))
	input()
	aa = list(map(int, input().split()))
	bb = list(map(int, input().split()))
	t = c2 // c1
	(c5, c6) = (sum((c1 * x if x <= t else c2 for x in l)) for l in (aa, bb))
	print(min(c3 * 2, c3 + c5, c3 + c6, c5 + c6, c4))

def __starting_point():
	main()
__starting_point()


(c1, c2, c3, c4) = map(int, input().split())
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cur1 = 0
for i in a:
	cur1 += min(i * c1, c2)
cur2 = 0
for i in b:
	cur2 += min(i * c1, c2)
answ = min(cur1 + cur2, c3 + cur2, cur1 + c3, 2 * c3)
print(min(answ, c4))


(c1, c2, c3, c4) = input().split()
(c1, c2, c3, c4) = (int(c1), int(c2), int(c3), int(c4))
(sizebus, sizetra) = input().split()
(sizebus, sizetra) = (int(sizebus), int(sizetra))
arrbus = input().split()
arrbus = [int(x) for x in arrbus]
arrtra = input().split()
arrtra = [int(x) for x in arrtra]
soma = 0
somabus = 0
somatra = 0
for i in range(sizebus):
	somabus += arrbus[i] * c1
	if arrbus[i] * c1 < c2:
		continue
	else:
		somabus -= arrbus[i] * c1
		somabus += c2
somabus = min(somabus, c3)
for i in range(sizetra):
	somatra += arrtra[i] * c1
	if arrtra[i] * c1 < c2:
		continue
	else:
		somatra -= arrtra[i] * c1
		somatra += c2
somatra = min(somatra, c3)
soma = min(c4, somabus + somatra)
print(soma)


I = lambda : map(int, input().split())
(c1, c2, c3, c4) = I()
I()
A = [min(a * c1, c2) for a in I()]
B = [min(b * c1, c2) for b in I()]
print(min(min(c3, sum(A)) + min(c3, sum(B)), c4))


t_costs = [int(x) for x in input().split(' ')]
num_tp = [int(x) for x in input().split(' ')]
num_buses = [int(x) for x in input().split(' ')]
num_trolleys = [int(x) for x in input().split(' ')]

def calculate_spent(t_costs, num_tp, num_buses, num_trolleys):
	bus = 0
	trolley = 0
	for i in num_buses:
		bus += min(t_costs[0] * i, t_costs[1])
	bus = min(bus, t_costs[2])
	for j in num_trolleys:
		trolley += min(t_costs[0] * j, t_costs[1])
	trolley = min(trolley, t_costs[2])
	cost = min(bus + trolley, t_costs[3])
	print(cost)
calculate_spent(t_costs, num_tp, num_buses, num_trolleys)


import sys
line_id = 0
for line in sys.stdin:
	line_id = line_id + 1
	line_data = line.split()
	if line_id <= 2:
		if line_id == 1:
			c1 = int(line_data[0])
			c2 = int(line_data[1])
			c3 = int(line_data[2])
			c4 = int(line_data[3])
		else:
			cnt_bus = int(line_data[0])
			cnt_tro = int(line_data[1])
	elif line_id == 3:
		cnt_bus_took = [0]
		for data_str in line_data:
			cnt_bus_took.append(int(data_str))
	else:
		cnt_tro_took = [0]
		for data_str in line_data:
			cnt_tro_took.append(int(data_str))
cost_bus = 0
for bus_id in range(cnt_bus + 1):
	cost_bus = cost_bus + min(c1 * cnt_bus_took[bus_id], c2)
cost_bus = min(c3, cost_bus)
cost_tro = 0
for tro_id in range(cnt_tro + 1):
	cost_tro = cost_tro + min(c1 * cnt_tro_took[tro_id], c2)
cost_tro = min(c3, cost_tro)
cost_all = min(c4, cost_bus + cost_tro)
print(cost_all)


I = lambda : map(int, input().split())
(c1, c2, c3, c4) = I()
I()
x = sum((min(a * c1, c2) for a in I()))
y = sum((min(b * c1, c2) for b in I()))
print(min(min(c3, x) + min(c3, y), c4))


def findLess(l, c1, c2, c3):
	ans = 0
	for i in l:
		ans += min(c2, i * c1)
	return min(ans, c3)
(c1, c2, c3, c4) = map(int, input().split())
input()
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
ans4 = c4
ans1 = findLess(l1, c1, c2, c3)
ans2 = findLess(l2, c1, c2, c3)
print(str(min(c4, ans2 + ans1)), end='')


(c1, c2, c3, c4) = map(int, input().split())
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
s = []
s0 = 0
for i in range(n):
	s.append(min(a[i] * c1, c2))
	s0 += s[i]
s1 = []
s10 = 0
for i in range(m):
	s1.append(min(b[i] * c1, c2))
	s10 += s1[i]
print(min(min(s0, c3) + min(s10, c3), c4))


(a, b, c, d) = input().split()
(a, b, c, d) = (int(a), int(b), int(c), int(d))
(n, m) = input().split()
(n, m) = (int(n), int(m))
nums1 = list(map(int, input().split()))
nums2 = list(map(int, input().split()))
nums1.sort(reverse=True)
nums2.sort(reverse=True)
m1 = 0
for i in nums1:
	if i * a < b:
		m1 += i * a
	else:
		m1 += b
m2 = b * len(nums1)
m3 = c
l1 = [m1, m2, m3]
m5 = 0
for i in nums2:
	if i * a < b:
		m5 += i * a
	else:
		m5 += b
m6 = b * len(nums2)
m7 = c
l2 = [m5, m6, m7]
res = float('inf')
for i in l1:
	for j in l2:
		res = min(res, i + j)
res = min(res, d)
print(res)


entrada = input().split()
aux = input()
buses = input().split()
carros = input().split()
c1 = int(entrada[0])
c2 = int(entrada[1])
c3 = int(entrada[2])
c4 = int(entrada[3])
buses = [int(valor) for valor in buses]
carros = [int(valor) for valor in carros]
buses.sort()
carros.sort()
precoBuses = 0
for valor in buses:
	precoBuses += c1 * valor
precoCarro = 0
for valor in carros:
	precoCarro += c1 * valor
if buses[-1] * c1 > c2:
	precoBuses = 0
	for valor in buses:
		if valor * c1 < c2:
			precoBuses += valor * c1
		else:
			precoBuses += c2
if carros[-1] * c1 > c2:
	precoCarro = 0
	for valor in carros:
		if valor * c1 < c2:
			precoCarro += valor * c1
		else:
			precoCarro += c2
if precoBuses > c3:
	precoBuses = c3
if precoCarro > c3:
	precoCarro = c3
if precoCarro + precoBuses > c4:
	print(c4)
else:
	print(precoCarro + precoBuses)


(c1, c2, c3, c4) = map(int, input().split())
(n, m) = map(int, input().split())
bus = list(map(int, input().split()))
trol = list(map(int, input().split()))
mbus = [0] * n
mtrol = [0] * m
for i in range(n):
	mbus[i] = min(bus[i] * c1, c2)
sbus = min(sum(mbus), c3)
for i in range(m):
	mtrol[i] = min(trol[i] * c1, c2)
strol = min(sum(mtrol), c3)
res = min(sbus + strol, c4)
print(res)


(c1, c2, c3, c4) = list(map(int, input().split()))
(n, m) = list(map(int, input().split()))
lst1 = list(map(int, input().split()))
lst2 = list(map(int, input().split()))
buss = 0
for i in lst1:
	buss += min(c1 * i, c2)
buss = min(buss, c3)
tr = 0
for i in lst2:
	tr += min(c1 * i, c2)
tr = min(tr, c3)
print(min(c4, buss + tr))


(c1, c2, c3, c4) = map(int, input().split())
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
(mn1, mn2) = (0, 0)
for i in range(n):
	if a[i] < c2 // c1 + 1:
		mn1 += c1 * a[i]
	else:
		mn1 += c2
for i in range(m):
	if b[i] < c2 // c1 + 1:
		mn2 += c1 * b[i]
	else:
		mn2 += c2
print(min(c4, 2 * c3, mn1 + c3, mn2 + c3, mn1 + mn2))


import sys
input = sys.stdin.readline
l = input().split()
c1 = int(l[0])
c2 = int(l[1])
c3 = int(l[2])
c4 = int(l[3])
l = input().split()
n = int(l[0])
m = int(l[1])
l = input().split()
ai = [int(i) for i in l]
l = input().split()
bi = [int(i) for i in l]
maxa = c4
sumi = 0
for i in ai:
	sumi += min(i * c1, c2)
sumi = min(sumi, c3)
sumi1 = 0
for i in bi:
	sumi1 += min(i * c1, c2)
sumi1 = min(sumi1, c3)
print(min(maxa, sumi + sumi1))


precos = [int(x) for x in input().split()]
numeros = [int(x) for x in input().split()]
bus = [int(x) for x in input().split()]
troler = [int(x) for x in input().split()]
somabus = 0
somatroler = 0
for e in bus:
	a = e * precos[0]
	b = precos[1]
	lista = [a, b]
	somabus += min(lista)
for e in troler:
	a = e * precos[0]
	b = precos[1]
	lista = [a, b]
	somatroler += min(lista)
lista2 = [somabus, precos[2]]
lista3 = [somatroler, precos[2]]
x = min(lista2) + min(lista3)
lista4 = [x, precos[3]]
print(min(lista4))


(a, b, c, d) = map(int, input().split())
(n, m) = map(int, input().split())
(s, ans) = (0, 0)
bus = list(map(int, input().split()))
tr = list(map(int, input().split()))
for i in bus:
	s = s + min(b, a * i)
for i in tr:
	ans = ans + min(b, a * i)
print(min(d, min(s, c) + min(ans, c)))


(c1, c2, c3, c4) = map(int, input().split())
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
s = min(c1, c2, c3, c4)
l = []
required = 0
for i in range(n):
	required = required + min(c2, c1 * a[i])
ans = min(c3, required)
required = 0
for i in range(m):
	required = required + min(c2, c1 * b[i])
ans = ans + min(c3, required)
print(min(ans, c4))


def readln():
	return tuple(map(int, input().split()))
c = readln()
(n, m) = readln()
a = readln()
b = readln()
va = min(sum([min(c[1], c[0] * _) for _ in a]), c[2])
vb = min(sum([min(c[1], c[0] * _) for _ in b]), c[2])
print(min(va + vb, c[3]))