MYQ1 - The Blind Passenger

The seats of an Ultra Deluxe Semi-sleeper bus in Thuvax country are numbered according to the following rules:

  1. Seat number 1 is reserved for the bus conductor.
  2. Remaining seats are numbered as shown in the figure below.
  3. The seating arrangement is as shown below.
    RowNo Left   Right
          W  A   A  M  W
                      
          01 
    1     02 03  04 05 06
    2     11 10  09 08 07
    3     12 13  14 15 16
    4     21 20  19 18 17
    5     22 ............    
       

A blind person enters the bus with a reservation ticket mentioning his seat number. He meets you at the start of the passage and shows you his ticket. Based on the seat number, help him find his seat by telling him the row number (1, 2 ...), seat position (window or aisle or middle), and the direction (left or right).

Input

First line contains a positive integer t (t <= 105) denoting the number of test cases.

Each of the next t lines contain a positive integer n (n <= 109) denoting the blind person's seat number.

Output

Output one line for every test case in the following format:

  • If the seat number is same as the conductor's seat, print "poor conductor"
  • else, print
    • row_number: represents the row number from the entrance (a positive integer)  
    • seat_position: can be one of "W" or "A" or "M" for window, aisle and middle respectively.
    • direction: can be either "L" or "R" for left or right respectively.

Example

Input:
3
1
2
3

Output:
poor conductor
1 W L
1 A L

Added by:jack(chakradarraju)
Date:2012-02-14
Time limit:0.503s-1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Bytecode 2012

hide comments
2013-03-07 16:53:58 Sivaraman Nagarajan
few discussions here are mis directing :( wasted twice for no reason
2013-02-16 11:40:10 Yo Yo Honey Singh
use scanf/printf instead of cin/cout...
2013-01-07 18:39:01 preetam
why is my o(1) solution giving TLE???
2012-11-17 21:29:13 Erik Lonèarek
When position is M, you should print R as well. Also, no need for long long (int 64), 2^31 or int 32 is just enough.
2012-10-23 20:21:19 Tomasz
I did it but I have to idea how decrease time for acc.
2012-10-04 11:53:11 Vicky Singh
be careful seat no. 04 is at right side.
2012-09-09 05:29:00 AMAN KOHLI
my code id is 7618192 and i think i am right can you tell why this is giving wrong answer....

Last edit: 2012-09-09 05:39:53
2012-08-15 19:33:37 napster
my problem code is :7473567.....can anyone plzz help me as i'm fetting TLE.
2012-07-28 18:54:32 Mitch Schwartz
By itself, I agree this would be a tutorial problem. But it's part of a contest, and there have been some precedents to allow such problems in classical in order to keep the entire set intact.

Last edit: 2012-07-28 21:54:53
2012-07-28 14:06:30 devu
Poor Question, I think the problem setter should take tutorials for explaining the problem properly ,the seat number 4 is on the right or left is not at all obvious from the figure ,i tried both of them and got accepted in one,by the way this prroblem should be moved to tutorials
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.