Elevator

Time Limit: 3 Seconds    Memory Limit: 32768 KB

The highest building in our city has only one elevator.

The problem is that given the arrival time, starting floor and destination floor of each employee for the day, determine the fastest time in which the evevator can get each employeee to his or her destination.

The elevator starts on the first floor at time 0. Travelling from the pth floor to the qth takes abs(p-q) units of time. The elevator may also stand still if it's optimal. Assume that it does not take any time for employees to enter or exit the elevator.

Input

The input consists of a number of test cases. Each test case contains four lines. The first line contains the number N (which means the number of employees) (N<=5), then the following three lines contain 3*N numbers indicating the arrival time, starting floor and destination floor of the N employees. A negative N indicates the end of the test cases. All the input data fit in a 32-bit integer.

Output

For each test case, first print the test number (counting from 1) in one line, then output the fastest time in which the elevator can get each employee to his or her destination.

Sample Input

1
5
30
50
-1

Sample Output

Test 1:
49
Submit

Source: ZOJ Monthly, February 2005