There are two types of burgers in your restaurant — hamburgers and chicken burgers! To assemble a hamburger you need two buns and a beef patty. To assemble a chicken burger you need two buns and a chicken cutlet. 

You have $b$ buns, $p$ beef patties and $f$ chicken cutlets in your restaurant. You can sell one hamburger for $h$ dollars and one chicken burger for $c$ dollars. Calculate the maximum profit you can achieve.

You have to answer $t$ independent queries.


-----Input-----

The first line contains one integer $t$ ($1 \le t \le 100$) – the number of queries.

The first line of each query contains three integers $b$, $p$ and $f$ ($1 \le b, ~p, ~f \le 100$) — the number of buns, beef patties and chicken cutlets in your restaurant.

The second line of each query contains two integers $h$ and $c$ ($1 \le h, ~c \le 100$) — the hamburger and chicken burger prices in your restaurant.


-----Output-----

For each query print one integer — the maximum profit you can achieve.


-----Example-----
Input
3
15 2 3
5 10
7 5 2
10 12
1 100 100
100 100

Output
40
34
0



-----Note-----

In first query you have to sell two hamburgers and three chicken burgers. Your income is $2 \cdot 5 + 3 \cdot 10 = 40$.

In second query you have to ell one hamburgers and two chicken burgers. Your income is $1 \cdot 10 + 2 \cdot 12 = 34$.

In third query you can not create any type of burgers because because you have only one bun. So your income is zero.

Difficulty: interview

Starter code:

Solutions:
for i in range(int(input())):
    a,b,c=map(int,input().split())
    x,y=map(int,input().split())
    ans=0
    if x>y:
        ans=ans+x*min(a//2,b)
        a=(a-2*min(a//2,b))
        ans=ans+y*min(a//2,c)
    else :
        ans=ans+y*min(a//2,c)
        a=(a-2*min(a//2,c))
        ans=ans+x*min(a//2,b)
    print(ans)

for _ in range(int(input())):
    b, p, f = map(int, input().split())
    h, c = map(int, input().split())
    if h < c:
        h, c = c, h
        p, f = f, p
    ham = min(p, b // 2)
    ans = ham * h
    b -= 2 * ham
    chicken = min(f, b // 2)
    ans += chicken * c
    print(ans)

for cas in range(int(input())):
    b, p, f = map(int, input().split())
    h, c = map(int, input().split())
    b //= 2
    ans = 0
    if h >= c:
        ans += min(b, p) * h
        b -= min(b, p)
        ans += min(b, f) * c
    else:
        ans += min(b, f) * c
        b -= min(b, f)
        ans += min(b, p) * h
    print(ans)

t = int(input())
for z in range(t):
    a, b, c = list(map(int, input().split()))
    q, w = list(map(int, input().split()))
    if q >= w:
        print(q * min(a // 2, b) + min(max(0, (a - 2 * b)) // 2, c) * w)
    else:
        print(w * min(a // 2, c) + min(max(0, (a - 2 * c)) // 2, b) * q)


for _ in range(int(input())):
    b, p, f = list(map(int, input().split()))
    h, c = list(map(int, input().split()))
    b //= 2
    if h > c:
        if b < p:
            print(h * b)
        else:
            b -= p
            print(h * p + min(b, f) * c)
    else:
        if b < f:
            print(c * b)
        else:
            b -= f
            print(f * c + min(b, p) * h)


T = int(input())

for t in range(T):
	b, p, f = list(map(int, input().split()))
	h, c = list(map(int, input().split()))

	ans = 0

	if h > c:
		n = min(b // 2, p)

		ans += n * h

		b -= n * 2

		n = min(b // 2, f)

		ans += n * c

	else:
		n = min(b // 2, f)

		ans += n * c

		b -= n * 2

		n = min(b // 2, p)

		ans += n * h

	print(ans)


#E71_A

t = int(input())

for i in range(0, t):
    ln = [int(j) for j in input().split(" ")]
    b = ln[0]
    p = ln[1]
    f = ln[2]
    ln = [int(j) for j in input().split(" ")]
    h = ln[0]
    c = ln[1]
    b = b // 2
    m = 0
    if h > c:
        mn = min(b, p)
        m += mn * h
        b -= mn
        mn = min(b, f)
        m += mn * c
        b -= mn
    else:
        mn = min(b, f)
        m += mn * c
        b -= mn
        mn = min(b, p)
        m += mn * h
        b -= mn
    print(m)


t = int(input())
for query in range(t):
  b, p, f = list(map(int, input().split()))
  h, c = list(map(int, input().split()))
  if h > c:
    ans = h * min(b // 2, p)
    b -= min(b // 2, p) * 2
    ans += c * min(b // 2, f)
    print(ans)
  else:
    ans = c * min(b // 2, f)
    b -= min(b // 2, f) * 2
    ans += h * min(b // 2, p)
    print(ans)


for _ in range(int(input())):
    b, p, f = map(int, input().split())
    h, c = map(int, input().split())
    n = b // 2
    res = 0
    for i in range(min(n, p) + 1):
        j = min(n - i, f)
        res = max(res, h * i + c * j)
    print(res)

for q in range(int(input())):
    x, y, z = list(map(int, input().split()))
    h, c = list(map(int, input().split()))
    if h < c:
        y, z, h, c = z, y, c, h
    if x <= y*2:
        print(x//2*h)
    else:
        print(y*h+min((x-2*y)//2, z)*c)


T = int(input())
for i in range(T):
    b, p, f = list(map(int, input().split()))
    h, c = list(map(int, input().split()))
    ans = 0
    if h > c:
        bur = min(b//2, p)
        ans += h*bur
        b -= bur*2

        ans += min(b//2, f) * c
    else:
        fish = min(b//2, f)
        ans += c*fish
        b -= fish*2

        ans += min(b//2, p) * h
    print(ans)


t = int(input())
for i in range(t):
    b,p,f = list(map(int,input().split()))
    h,c = list(map(int,input().split()))
    if h > c:
        num = min(b//2,p)
        b -= num * 2
        num2 = min(b//2,f)
        print(num * h + num2 * c)
    else:
        num = min(b//2,f)
        b -= num * 2
        num2 = min(b//2,p)
        print(num * c + num2 * h)


import sys 
from collections import defaultdict
input = lambda : sys.stdin.readline().rstrip()

for t in range(int(input())):
  b, p, f = list(map(int, input().split()))
  h, c = list(map(int, input().split()))

  if h >= c:
    beef = min((b//2), p)
    b -= beef * 2
    chicken = min((b//2), f)
    print(beef*h + chicken*c)
  else:
    chicken = min((b//2), f)
    b -= chicken * 2
    beef = min((b//2), p)
    print(beef*h + chicken*c)


for _ in range(int(input())):
    b,p,f=list(map(int,input().split()))
    h,c=list(map(int,input().split()))
    ans=0
    for beef in range(p+1):
        buns=b-2*beef
        chick=min(buns//2,f)
        if(buns<0):
            continue
        ans=max(ans,beef*h+c*chick)
    print(ans)


t = int(input())
for i in range(t):
	b, p, f = map(int, input().split())
	h, c = map(int, input().split())
	if h < c:
		h,c = c,h
		p,f = f,p
	
	b //= 2
	
	resp = 0
	ff = min(b, p)
	b -= ff
	resp += h * ff
	
	ff = min(b, f)
	resp += c * ff
	print(resp)

#JMD
#Nagendra Jha-4096

 
import sys
import math

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

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
t=int(input())
for tt in range(t):
    #n=int(input())
    b,p,f= map(int, sys.stdin.readline().split(' '))
    h,c= map(int, sys.stdin.readline().split(' '))
    b=b//2

    ans=0
    if h>=c:
        val=min(b,p)
        ans+=val*h
        b-=val

        val=min(b,f)
        ans+=val*c
    else:
        val=min(b,f)
        ans+=val*c
        b-=val
        val=min(b,p)
        ans+=val*h

    print(ans)
    #a=list(map(int,sys.stdin.readline().split(' ')))
    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

t=int(input())
for nt in range(t):
    b,p,f=[int(k) for k in input().split(" ")]
    h,c=[int(k) for k in input().split(" ")]
    if c>h:
        c,h=h,c
        p,f=f,p
    res=0
    nbmx=min(b//2,p)
    b-=nbmx*2
    nbmn=min(b//2,f)
    res=nbmx*h+nbmn*c
    print(res)


t = int(input())
for i in range(t):
    b, p, f = map(int, input().split())
    h, c = map(int, input().split())
    b //= 2
    ans = 0
    for i in range(b + 1):
        ans = max(ans, min(p, i) * h + min(f, b - i) * c)
    print(ans)

from sys import stdin
n=int(stdin.readline().strip())
for i in range(n):
    v,p,f=list(map(int,stdin.readline().strip().split()))
    h,c=list(map(int,stdin.readline().strip().split()))
    ans=0
    for j in range(101):
        for k in range(101):
            v1,p1,f1=v,p,f
            v1-=2*j
            p1-=j
            v1-=2*k
            f1-=k
            if(v1>=0 and p1>=0 and f1>=0):
                ans=max(ans,h*j+c*k)
    print(ans)
            


t = int(input())
while t:
    b, p, f = map(int, input().split())
    h, c = map(int, input().split())
    ans = 0
    if h > c:
        ans += min(b // 2, p) * h
        b -= 2 * p
        if b > 0:
            ans += min(b // 2, f) * c
    else:
        ans += min(b // 2, f) * c
        b -= 2 * f
        if b > 0:
            ans += min(b // 2, p) * h
    print(ans)
    t -= 1

for _ in range(int(input())):
    b, p, f = list(map(int,input().split()))
    h, c = list(map(int,input().split()))
    res = 0
    b //= 2
    if h > c:
        res += min(p, b) * h
        b -= min(p, b)
        res += min(f, b) * c
    else:
        res += min(f, b) * c
        b -= min(f, b)
        res += min(p, b) * h
    print(res)

t = int( input() )
for _ in range(t):
    b, p, f = list(map( int, input().split() ))
    h, c = list(map( int, input().split() ))
    b //= 2
    if h < c:
        p, f = f, p
        h, c = c, h
    p = min( b, p )
    b -= p
    f = min( b, f )
    print( p * h + f * c )


n = int(input())
for i in range(n):
    b, c, d = list(map(int, input().split()))
    e, f = list(map(int, input().split()))
    ans = 0
    if f > e:
        ans += min(b // 2, d) * f
        b -= min(b // 2 * 2, d * 2)
        if b > 1:
            ans += min(b // 2, c) * e
    else:
        ans += min(b // 2, c) * e
        b -= min(b // 2 * 2, c * 2)
        if b > 1:
            ans += min(b // 2, d) * f
    print(ans)


''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''
#codeforces1207A_live
gi = lambda : list(map(int,input().split()))
for k in range(gi()[0]):
	b, p, f = gi()
	h, c = gi()
	ans = 0
	if h > c:
		tmep = min(b // 2, p)
		ans += tmep * h
		b -= tmep * 2
		ans += min(b // 2, f) * c
	else:
		tmep = min(b // 2, f)
		ans += tmep * c
		b -= tmep * 2
		ans += min(b // 2, p) * h
	print(ans)

for i in range(int(input())):
	b, p, f = list(map(int, input().split()))
	h, c = list(map(int, input().split()))
	mc = 0
	if h > c:
		mc += h * min(b // 2, p)
		b, p = b - 2 * min(b // 2, p), p - min(b // 2, p)
		mc += c * min(b // 2, f)
	else:
		mc += c * min(b // 2, f)
		b, f = b - 2 * min(b // 2, f), p - min(b // 2, f)
		mc += h * min(b // 2, p)
	print(mc)