Jiwoo manages the ACM Hotel and gives each guest an empty room as the guest arrives. A survey says that guests prefer the room with the shortest walking distance from the hotel entrance. Write a program that assigns rooms by that result.
To keep the problem simple, assume the hotel is a rectangle. It has H floors with W rooms on every floor, and the elevator is at the far left. A hotel of this shape is called an H×W hotel. The entrance is right in front of the elevator on floor 1, and the distance from the entrance to the elevator is ignored. Every two adjacent rooms are at distance 1, and rooms exist only along the front of the hotel.
A room number has the form YXX or YYXX. Y or YY is the floor, and XX is the position counted from the elevator. For example, the fifth room from the elevator on floor 3 is room 305.
A guest does not care how far the elevator travels. When the walking distance is the same, a guest prefers the lower floor. Room 301 is preferred over room 102, because room 102 needs a walk of distance 2 while room 301 needs a walk of distance 1. For the same reason room 2101 is preferred over room 102.
Every room is empty at the start. Find the room number given to the Nth guest under this policy. The first guest takes room 101 and the second guest takes room 201. In a hotel with H=6 and W=12, the 10th guest takes room 402.
The first line has the number of test data T. Each of the next T lines has three integers H, W, N, in that order the number of floors, the number of rooms on each floor, and which guest to place (1≤H,W≤99, 1≤N≤H×W).
For each test data, print the room number given to the Nth guest on one line.