1421_D. Hexagons
Lindsey Buckingham told Stevie Nicks ["Go your own way"](https://www.youtube.com/watch?v=6ul-cZyuYq4). Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.

Consider a hexagonal tiling of the plane as on the picture below.

<image>

Nicks wishes to go from the cell marked (0, 0) to a certain cell given by the coordinates. She may go from a hexagon to any of its six neighbors you want, but there is a cost associated with each of them. The costs depend only on the direction in which you travel. Going from (0, 0) to (1, 1) will take the exact same cost as going from (-2, -1) to (-1, 0). The costs are given in the input in the order c_1, c_2, c_3, c_4, c_5, c_6 as in the picture below.

<image>

Print the smallest cost of a path from the origin which has coordinates (0, 0) to the given cell.

Input

Each test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^{4}). Description of the test cases follows.

The first line of each test case contains two integers x and y (-10^{9} ≤ x, y ≤ 10^{9}) representing the coordinates of the target hexagon.

The second line of each test case contains six integers c_1, c_2, c_3, c_4, c_5, c_6 (1 ≤ c_1, c_2, c_3, c_4, c_5, c_6 ≤ 10^{9}) representing the six costs of the making one step in a particular direction (refer to the picture above to see which edge is for each value).

Output

For each testcase output the smallest cost of a path from the origin to the given cell.

Example

Input


2
-3 1
1 3 5 7 9 11
1000000000 1000000000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000


Output


18
1000000000000000000

Note

The picture below shows the solution for the first sample. The cost 18 is reached by taking c_3 3 times and c_2 once, amounting to 5+5+5+3=18.

<image>
```python
import sys
input=sys.stdin.buffer.readline #FOR READING PURE INTEGER INPUTS (space separation ok)
#import sys
#input=lambda: sys.stdin.readline().rstrip("\r\n") #FOR READING STRING/TEXT INPUTS.
def oneLineArrayPrint(arr):
    print(' '.join([str(x) for x in arr]))
def multiLineArrayPrint(arr):
    print('\n'.join([str(x) for x in arr]))
def multiLineArrayOfArraysPrint(arr):
    print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))


import heapq,collections

def getSurroundings(i,j,currCost):
    return [(i+1,j+1,currCost+c1),
            (i,j+1,currCost+c2),
            (i-1,j,currCost+c3),
            (i-1,j-1,currCost+c4),
            (i,j-1,currCost+c5),
            (i+1,j,currCost+c6)]

allAns=[]
t=int(input())
for _ in range(t):
    x,y=[int(z) for z in input().split()]
    c1,c2,c3,c4,c5,c6=[int(z) for z in input().split()]
    
    minDist=collections.defaultdict(lambda:-1) #{(x,y):minDist}
    queue=[(0,(0,0))] #(cost,(i,j))
    
    coverCnts=0
    while coverCnts<6: #Dijkstra
        cost,(i,j)=heapq.heappop(queue)
        if minDist[(i,j)]==-1:
            minDist[(i,j)]=cost
            if (i,j) in {(1,1),(0,1),(-1,0),(-1,-1),(0,-1),(1,0)}:
                coverCnts+=1
            for iNext,jNext,costNext in getSurroundings(i,j,cost):
                if minDist[(iNext,jNext)]==-1 and abs(iNext)<=3 and abs(jNext)<=3: #search space of i and j need not exceed 3
                    heapq.heappush(queue,(costNext,(iNext,jNext)))
    
    c1,c2,c3,c4,c5,c6=[minDist[(1,1)],minDist[(0,1)],minDist[(-1,0)],
                               minDist[(-1,-1)],minDist[(0,-1)],minDist[(1,0)]]
    #try to get to x,y using a combination of 2 out of 3 axes:
    #axis1:y=0 (x only)
    #axis2:x=0(y only)
    #axis3:x-y=0(x and y)
    ans=float('inf')
    #axes 1 and 3
    t=y
    s=x-t
    ans2=0
    if t>=0:ans2+=c1*abs(t)
    else:ans2+=c4*abs(t)
    if s>=0:ans2+=c6*abs(s)
    else:ans2+=c3*abs(s)
    ans=min(ans,ans2)
    
    #axes 1 and 2
    s=x
    t=y
    ans2=0
    if s>=0:ans2+=c6*abs(s)
    else:ans2+=c3*abs(s)
    if t>=0:ans2+=c2*abs(t)
    else:ans2+=c5*abs(t)
    ans=min(ans,ans2)
    
    #axes 2 and 3
    t=x
    s=y-t
    ans2=0
    if s>=0:ans2+=c2*abs(s)
    else:ans2+=c5*abs(s)
    if t>=0:ans2+=c1*abs(t)
    else:ans2+=c4*abs(t)
    ans=min(ans,ans2)
    
    allAns.append(ans)

multiLineArrayPrint(allAns)
    
    
    
    
    



```