You are given two integers x and y. You can perform two types of operations: 

  1. Pay a dollars and increase or decrease any of these integers by 1. For example, if x = 0 and y = 7 there are four possible outcomes after this operation: 
    * x = 0, y = 6; 
    * x = 0, y = 8; 
    * x = -1, y = 7; 
    * x = 1, y = 7. 

  2. Pay b dollars and increase or decrease both integers by 1. For example, if x = 0 and y = 7 there are two possible outcomes after this operation: 
    * x = -1, y = 6; 
    * x = 1, y = 8. 



Your goal is to make both given integers equal zero simultaneously, i.e. x = y = 0. There are no other requirements. In particular, it is possible to move from x=1, y=0 to x=y=0.

Calculate the minimum amount of dollars you have to spend on it.

Input

The first line contains one integer t (1 ≤ t ≤ 100) — the number of testcases.

The first line of each test case contains two integers x and y (0 ≤ x, y ≤ 10^9).

The second line of each test case contains two integers a and b (1 ≤ a, b ≤ 10^9).

Output

For each test case print one integer — the minimum amount of dollars you have to spend.

Example

Input


2
1 3
391 555
0 0
9 4


Output


1337
0

Note

In the first test case you can perform the following sequence of operations: first, second, first. This way you spend 391 + 555 + 391 = 1337 dollars.

In the second test case both integers are equal to zero initially, so you dont' have to spend money.
# for _ in range(int(input())):
#     n,k=map(int,input().split())
#     arr = [int(x) for x in input().split()]
    # c=[0]*n
    # #d=[]
    # i=0
    # x=0
    # while(max(arr)!=-1):
    #     x=k-arr[i]
    #     if(arr!=-1):
    #         c[arr.index(arr[i])]=1
    #         arr[arr.index(arr[i])]= -1
    #         if(x in arr):
    #             while(x in arr):
    #                 arr[arr.index(x)]= -1
    #                 if(x in arr):
    #                     c[arr.index(x)]=1
    #                     arr[arr.index(x)]= -1
    #     i+=1
    # print(" ".join(str(gh) for gh in c))
    # ans = 0
    # c=1
    # for i in range(n):
    #     if(2*arr[i] == k):
    #         c=c+1
    #         ans=(c)%2
    #     else:
    #         if(2*a[i]<k):
    #             ans = 0
    #         else:
    #             ans=1
    #     print(str(ans),end=" ")
    # print("\n")
########################
#                        #
#     COLOUR REVOLUTIONN    #
#                        #
#####################

# for _ in range(int(input())):
#     n,k=map(int,input().split())
#     if(k != 1):
#         a = abs((1-(k**4))//(1-k))
#         n1 = n//a
#     else:
#         n1 = 1
#     for i in range(4):
#         print(str(n1*(k**i)),end=' ')
#     print('\n')

########################################

#            CABEL CAR                 #

########################################

# r,g,b = map(int,input().split())
# co = -1
# while(r >0 or g>0 or b>0):
#     co += 1
#     r -= 2
#     if(r <=0 and g<=0 and b<=0):
#         break
#     co += 1
#     g -= 2
#     if(r <=0 and g<=0 and b<=0):
#         break
#     co+=1
#     b-=2
# print(co+30)

########################################

#            ROAD TO ZERO              #

########################################

for _ in range(int(input())):
    x,y = map(int, input().split())
    a,b = map(int, input().split())
    a1 = min(x,y)
    b1=max(x,y)
    op1=0
    op2=0
    if(a*2 <= b):
        print((x+y)*a)
    else:
        op1=a1*b
        op2=(b1-a1)*a
        print(op1+op2)