Under construction

Still being built. Things may change

Virtual Verification Technology

Interview

Time limit1sMemory limit1024 MB

Summary
Two researchers split simulations for models A and B, and only the senior can run B, so find the minimum time to finish all of them.
Level

Easy3 of 10

Topics
Brute force, Math
Solved
No attempts yet

Problem

Hyundai AutoEver's virtual verification technology virtualizes vehicles, systems, and controllers, and provides a virtual driving environment and verification tools. It lets engineers run function-level verification, cross-function verification, and system-level verification without hardware. Virtual verification secures quality through early verification and simulates adverse conditions that cannot be tested in the real world. As the computing complexity of vehicles grows in the SDV era, virtual verification is an effective way to secure vehicle safety and performance against software quality risks of a different kind.

Dohun, a senior researcher, and Sanghyuk, a new researcher, are in charge of virtual verification for vehicle models AA and BB. One virtual verification simulation for model AA takes TAT_A time, and one for model BB takes TBT_B time. Model AA needs VAV_A verification items tested, and model BB needs VBV_B items tested. Each simulation tests exactly one verification item.

Dohun is a senior researcher who can run virtual verification for both models AA and BB. Sanghyuk is a new researcher who can run verification only for model AA. Dohun and Sanghyuk each run one simulation at a time, and they cannot simulate the same verification item. They assume no time is needed to prepare the next simulation after finishing one. A simulation cannot be stopped once it starts.

The work is complete when all simulations for both models are finished. Find the minimum time Dohun and Sanghyuk need to complete the virtual verification work.

Input

The first line contains the number of test cases QQ. (1≤Q≤1 000)(1 \leq Q \leq 1\,000)

From the second line onward, each test case is given on one line as TAT_A, TBT_B, VAV_A, and VBV_B, separated by spaces. Here TAT_A and TBT_B are the time for one simulation of models AA and BB, and VAV_A and VBV_B are the numbers of verification items for models AA and BB. (1≤TA,TB,VA,VB≤100)(1 \leq T_A, T_B, V_A, V_B \leq 100)

Output

For each test case, print on its own line the minimum time needed to complete the work.

Examples1

  1. Example 1

    Input
    4
    3 3 7 5
    2 3 5 7
    3 2 7 5
    2 1 1 1
    
    Expected output
    18
    21
    16
    2