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

1 ≤ T ≤ 104

1 ≤ N, Sa, Sb, Sc ≤ 109

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.081s 0.012s 13