# Input

• The first line contains an integer T, the number of test cases. Then the test cases follow.
• Each test case contains a single line of input, four integers dd, x, y, z.

# Output

For each testcase, output in a single line the answer to the problem.

# Constraints

• 1≤T≤5⋅10³
• 1≤d<7
• 1≤z<x<y≤18

Subtask #1 (100 points): Original constraints

# Sample Input

`31 2 3 16 2 3 11 2 8 1`

`141914`

# Explanation

Test Case 1: Using the first strategy, Chef does 2⋅7=14 units of work and using the second strategy Chef does 3⋅1+1⋅6=9 units of work. So the maximum amount of work that Chef can do is max(14,9)=14 units by using the first strategy.

`/* package codechef; // don't place package name! */import java.util.*;import java.lang.*;import java.io.*;/* Name of the class has to be "Main" only if the class is public. */class Codechef{ public static void main (String[] args) throws java.lang.Exception {  // your code goes here  Scanner sc = new Scanner(System.in);  int t = sc.nextInt();    while(t-- > 0){      long d = sc.nextLong();      long x = sc.nextLong();      long y = sc.nextLong();      long z = sc.nextLong();            System.out.println(Math.max(x*7,(y*d+(z*(7-d)))));        } }}`

--

-- ## Anubhav Mishra

Software Developer ,currently pursuing B.Tech in Information Technology. Electronic Dance Music is love.Also like all phone related technologies