Sitting (Large)

Find the maximum number of players seatable in an R by C grid so no player has occupied seats on both sides horizontally or vertically.

Medium5GreedyMathImplementationBrute forceNo attempts yetTime limit5sMemory limit512 MB

Problem

The opening ceremony of a game world championship is about to start. The players sit in a grid of seats with RR rows and CC columns.

The competition is fierce, and a player dislikes having future opponents right next to them. A player feels crowded if another player sits in the seat directly to their left and another player sits in the seat directly to their right. A player also feels crowded if one player sits directly in front of them and another player sits directly behind them.

Find the largest number of players that can be seated so that no player feels crowded.

Input

The first line contains the number of test cases TT. TT test cases follow. Each test case is one line with two integers RR and CC: the number of rows and the number of columns of seats.

Output

For each test case, print one line in the form Case #x: y, where xx is the test case number starting from 1 and yy is the largest number of players that can be seated so that no player feels crowded.

Constraints

  • 1T1001 \le T \le 100
  • 1R1001 \le R \le 100
  • 1C1001 \le C \le 100

Note

With R=2R = 2 and C=2C = 2, all four seats can be filled and no player feels crowded.

With R=2R = 2 and C=3C = 3, a row cannot hold three players, because the middle one would feel crowded. Filling the first two columns seats four players, and nothing better exists.

With R=4R = 4 and C=1C = 1, filling the first two rows and the last row is optimal and seats three players.