AT_abc462_e [ABC462E] Alternating Costs

Description

You are given integers $ A,B,X,Y $ . A piece is placed on a two-dimensional plane. Initially, the piece is at coordinate $ (0,0) $ . You can perform the following operation zero or more times: - Let the current coordinate of the piece be $ (x,y) $ . Move the piece to one of the coordinates $ (x-1,y),(x+1,y),(x,y-1),(x,y+1) $ . The cost of the $ k $ -th operation ( $ k \geq 1 $ ) depends on the parity of $ k $ , as follows: - If $ k $ is odd: Let the current coordinate of the piece be $ (x,y) $ . The cost of moving to $ (x-1,y) $ or $ (x+1,y) $ is $ A $ , and the cost of moving to $ (x,y-1) $ or $ (x,y+1) $ is $ B $ . - If $ k $ is even: Let the current coordinate of the piece be $ (x,y) $ . The cost of moving to $ (x-1,y) $ or $ (x+1,y) $ is $ B $ , and the cost of moving to $ (x,y-1) $ or $ (x,y+1) $ is $ A $ . Find the minimum total cost required to move the piece to coordinate $ (X,Y) $ . $ T $ test cases are given; solve each one.

Input Format

The input is given from Standard Input in the following format: > $ T $ $ \text{case}_1 $ $ \text{case}_2 $ $ \vdots $ $ \text{case}_T $ The $ i $ -th ( $ 1\le i\le T $ ) test case $ \text{case}_i $ is given in the following format: > $ A $ $ B $ $ X $ $ Y $

Output Format

Output the answers for the test cases in order, each on a separate line.

Explanation/Hint

### Sample Explanation 1 Consider the first test case. The following moves cost $ 4 $ in total: - Move the piece from $ (0,0) $ to $ (-1,0) $ . This costs $ 1 $ . - Move the piece from $ (-1,0) $ to $ (-1,1) $ . This costs $ 1 $ . - Move the piece from $ (-1,1) $ to $ (-1,2) $ . This costs $ 2 $ . It is impossible to move the piece to $ (-1,2) $ with a total cost less than $ 4 $ , so output $ 4 $ on the first line. ### Constraints - $ 1\le T\le 2\times 10^5 $ - $ 1\le A,B\le 10^9 $ - $ -10^9\le X,Y\le 10^9 $ - All input values are integers.