Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Game of Lands

Limits: 500ms, 256 MB

Two big houses, The Lanisters and the Starks are fighting over the 7 kingdoms having infinite lands. To stop the war and to bring peace Danny came up with a solution. She will denote each land with a positive integer number. Then the Lannisters will make 1 move and take odd number of lands starting from 1. Then the Starks will start after 1, make two moves and take two even numbered lands, which are 2 and 4 respectively. Then the Lannisters will make 3 moves and take three odd numbered lands after 4, that are 5,7,9. And so on. One can take only one land in a single move. Also one land can only be taken once.

Danny is good with dragons. But a meteorite crash killed all the dragons. So now she has hired Jon Snow to do her job, that is determining who will take which numbered land at a specific move.

Input

First line will take an integer T. The number of test cases. The following T lines will take an integer n.

1<= T <= 1000
1<= n <= 1,000,000,000,000,000

Output

Print the case number and the number of that land, which will be taken at the n-th move.

Samples

InputOutput
3
1
3
7
Case 1: 1
Case 2: 4
Case 3: 10

Discussion
Submit

Login to submit