# Seating Arrangement Problem

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

You will be given a seat number, find out the seat number facing you and the seat type, i.e. WS, MS or 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

SAMPLE INPUT

```2
18
40```

SAMPLE OUTPUT

```19 WS
45 AS```

My Solution in Java:-

``````//Package For the Buffered Reader
class TestClass {
public static void main(String args[] ) throws Exception {

int[] N = new int[T];

for(int i=0;i<T;i++) {
}

for(int i=0;i<T;i++) {

if(N[i]%6==0 || N[i]%6==1) {
if(N[i]%12==0)
System.out.print((N[i]-11) + " WS");
else if(N[i]%12==1)
System.out.print((N[i]+11) + " WS");
else if(N[i]%6==0)
System.out.print((N[i]+1) + " WS");
else
System.out.print((N[i]-1) + " WS");
System.out.println();
}
else if((N[i]-2)%3==0) {
if(N[i]%12==2)
System.out.print(N[i]+9 +" MS");
else if((N[i]-3)%12==2)
System.out.print(N[i]+3 +" MS");
else if((N[i]-6)%12==2)
System.out.print(N[i]-3 +" MS");
else
System.out.print(N[i]-9 +" MS");
System.out.println();
}
else {
if((N[i]-3)%12==0)
System.out.print((N[i]+7) +" AS");
else if(N[i]%12==4)
System.out.print((N[i]+5) +" AS");
else if(N[i]%12==9)
System.out.print((N[i]-5) +" AS");
else
System.out.print((N[i]-7) +" AS");
System.out.println();
}
}
}
}``````

Please feel free to post your solution in different languages or if any other more optimal solution.