Bayan Shortcut Round Problem

This question was asked in Bayan Shortcut Round-2014.Can someone please help me on solving this problem?It goes as follows:

A country has a+b cities located in a row, which are uniformely placed. There are two large telecommunication operators in this country. The first operator will install BTSs in a cities and the other operator would install BTSs on the remaining b cities. A base transceiver station (BTS) is a piece of equipment that facilitates wireless communication between user equipment (UE) and a network. Communication between two cities supported by the same operator has no cost. Otherwise the cost of communication between those two cities would be equal to their distance. Distance of two cities is equal to the number of cities strictly between them. The operators have decided to install their BTSs, trying to minimize the total cost. The total cost is defined as the sum of communication costs for every pair of cities. In other words, for each pair of cities with different operators, they calculate the number of cities located between them and they intend to minimize sum of these values. Moreover, the operators want to calculate the number of ways they can install their BTSs, while minimizing the total cost. Two ways of installation are considered different if there exists a city which has different operators in those two. The number of ways to install BTSs can be very large, it is enough to calculate it modulo 10^9+7.

Input

The first line contains an integer T, number of test cases. Each test case is preceded by an empty line. The only line of each test case contains two integers a and b, denoting the number of BTSs of each operator.

1≤T≤100

0≤a,b≤10^6​​

1≤a+b

Output

For each test case, first output a line containing Case #x:

, where <code dir="ltr">x

is the test case number, starting from (1). On the next line, output two space separated integers, the minimum total cost and the number of ways to achieve it.

Sample Input

4

3 1

4 1

3 2

4 2

Sample Output

Case #1:
1 2
Case #2:
2 1
Case #3:
4 1
Case #4:
8 4