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

hide comments
Arpit Temani: 2014-02-26 15:43:38

wa
any tricky cases

Mercury: 2014-02-12 21:54:38

same solution giving TLE in C++ and AC in C . I think it has something to do with printf over cout :P

Last edit: 2014-02-12 21:55:35
مجد : 2014-02-04 02:37:17

tle ?? for god's sake !!

Gaurav Panwar: 2014-01-19 09:03:43

use ill and double cause me 5 wa's

Ruchir Sharma: 2013-11-26 18:38:04

O(1) Solution giving TLE.. :/ is there any problem in Input ?

joud zouzou: 2013-08-20 18:15:27

Same Code One time TLE and another time AC

Hasil Sharma: 2013-07-27 15:35:13

nice problem :)

Alien: 2013-06-06 07:18:38

Good logic behind the question ,& seat 4,9....are on right side

Last edit: 2013-06-06 07:19:00
Chandan Mittal: 2013-05-27 20:40:31

what is the correct o/p for
1
1000000000

Himanshu: 2013-05-20 14:43:13

Brain Storming........


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