Processing math: 100%

Problem A. ABC

Author:A. Verkholat   Time limit:1 sec
Input file:Standard input   Memory limit:256 Mb
Output file:Standard output  

Statement

Given an empty string.

You can add to that string characters 'A', 'B' and 'C'.

Your should calculate maximum score you can get with a string of length N.

Input format

First line contains an integer T - number of tests.

Each test contains four integers: N, Sa, Sb and Sc.

Output format

For each test print one integer - maximum score.

Constraints

1T104

1N,Sa,Sb,Sc109

Sample tests

No. Standard input Standard output
1
3
3 2 7 1
4 6 1 3
5 3 1 6
18
30
30

0.151s 0.044s 13