Problem Statement:
Akash and Vishal are quite fond of travelling. They mostly travel by railways. They were travelling in a train one day and they got interested in the seating arrangement of their compartment. The compartment looked something like

So they got interested to know the seat number facing them and the seat type facing them. The seats are denoted as follows :
- Window Seat : WS
- Middle Seat : MS
- Aisle Seat : AS
INPUT
First line of input will consist of a single integer T denoting number of test-cases. Each test-case consists of a single integer N denoting the seat-number.
OUTPUT
For each test case, print the facing seat-number and the seat-type, separated by a single space in a new line.
CONSTRAINTS
- 1<=T<=105
- 1<=N<=108
Programming using python 2.7.6:
From the problem statement and seating arrangement it depicts that in each row there are 12 seats (6 in each side) and which means there are two window seats(WS), 2 middle seats(MS) and 2 aisle seats(AS).
Let's consider one row of seats and then it will be easy for us to get the solution.
Window Seat : Seat number 1, 6, 7 and 12 are WS.
The person who is seating at Seat no 12 is opposite to Seat no. 1 and the difference from Seat no. 1 to Seat no 12 is 11, i.e n+11 (Where n is given seat number). Similarly seat no 1 is opposite to Seat no. 12 and the difference from seat no. 12 to seat no 1 is 11 i.e n-11 (Where n is given seat number).
In the same way Seat no 7 is opposite to Seat no. 6 and the difference from Seat no. 6 to Seat no 7 is 1, i.e n+1 (Where n is given seat number) and Seat no 6 is opposite to Seat no. 7 and the difference from Seat no. 7 to Seat no 6 is 1, i.e n-1 (Where n is given seat number).
Middle Seat : Seat number 2, 5, 7 and 11 are MS.
The person who is seating at seat no 11 is opposite to Seat no. 2 and the difference from Seat no. 2 to Seat no 11 is 9, i.e n+9 (Where n is given seat number). Similarly Seat no 2 is opposite to Seat no. 11 and the difference from Seat no. 11 to Seat no 2 is 9 i.e n-9 (Where n is given seat number).
In the same way Seat no 8 is opposite to Seat no. 5 and the difference from Seat no. 5 to Seat no 5 is 3, i.e n+3 (Where n is given seat number) and Seat no 5 is opposite to Seat no. 8 and the difference from Seat no. 8 to Seat no 5 is 3, i.e n-3 (Where n is given seat number).
Aisle Seat : Seat number 3, 4, 9 and 10 are AS.
The person who is seating at seat no 10 is opposite to Seat no. 3 and the difference from Seat no. 3 to Seat no 10 is 9, i.e n+7 (Where n is given seat number). Similarly Seat no 10 is opposite to Seat no. 3 and the difference from Seat no. 10 to Seat no 3 is 7 i.e n-7 (Where n is given seat number).
In the same way Seat no 9 is opposite to Seat no. 4 and the difference from Seat no. 4 to Seat no 9 is 5, i.e n+5 (Where n is given seat number) and Seat no 4 is opposite to Seat no. 9 and the difference from Seat no. 9 to Seat no 4 is 5, i.e n-5 (Where n is given seat number).
Let's only consider Seat number 1 to 12 ,
There are total 12 seats and you divide your seat number by 12 , below will be your outcome:
If remainder is 1 then it's a WS and n+11 is the opposite person i.e. Seat number 12
If remainder is 2 then it's a MS and n+9 is the opposite person i.e. Seat number 11
If remainder is 3 then it's a AS and n+7 is the opposite person i.e. Seat number 10
In generic
if remainder is 0,1,6 and 7 then it's a WS
if remainder is 2,5,8 and 11 then it's MS
if remainder is 3,4,9 and 10 the it's AS
This can be coded using if..elif statement, since python does not support switch case.
Code in Python 2.7 :
NumberOfTestCases = int(raw_input())
SeatNumber = list()
rem = 0
while NumberOfTestCases:
SeatNumber.append(int(raw_input()))
NumberOfTestCases -=1
for i in range(len(SeatNumber)):
rem = SeatNumber[i]%12
if rem == 1: #Window Seat
print '{0} {1}'.format(SeatNumber[i]+11,'WS')
elif rem == 2: #Middle Seat
print '{0} {1}'.format(SeatNumber[i]+9,'MS')
elif rem == 3: #Aisle Seat
print '{0} {1}'.format(SeatNumber[i]+7,'AS')
elif rem == 4: #Aisle Seat
print '{0} {1}'.format(SeatNumber[i]+5,'AS')
elif rem == 5: #Middle Seat
print '{0} {1}'.format(SeatNumber[i]+3,'MS')
elif rem == 6: #Window Seat
print '{0} {1}'.format(SeatNumber[i]+1,'WS')
elif rem == 7: #Window Seat
print '{0} {1}'.format(SeatNumber[i]-1,'WS')
elif rem == 8: # Middle Seat
print '{0} {1}'.format(SeatNumber[i]-3,'MS')
elif rem == 9: #Aisle Seat
print '{0} {1}'.format(SeatNumber[i]-5,'AS')
elif rem == 10: #Aisle Seat
print '{0} {1}'.format(SeatNumber[i]-7,'AS')
elif rem == 11: #Middle Seat
print '{0} {1}'.format(SeatNumber[i]-9,'MS')
elif rem == 0: #Window Seat
print '{0} {1}'.format(SeatNumber[i]-11,'WS')
rem = 0