Compass Conundrum

View as PDF

Submit solution

Points: 100
Time limit: 1.0s
Memory limit: 977M

Author:
Problem type

Your child is going off onto a hike, but you are worried that they are going to get lost, starve, and die. Even worse is that they do not understand how compass bearings work. You decide to create a program to convert from compass bearings to true bearings in order to help.

A compass bearing takes the form AdB, where Ais one of N, S, and B is one of E and W, representing one of the four cardinal directions. d is an integer which states that the direction points d degrees away from A and towards B.

A true bearing takes the form cT, where 0 \le c \le 359, meaning that the direction is c degrees from North in a clockwise direction.

Input

The input will be a line containing an integer n. The following n lines will each have a compass bearing for you to convert to true bearing.

Output

n lines, listing out the directions in true bearings.

Constraints

  • 1 \le n \le 1000
  • 0 \le d \le 45

Example 1

Input
5
N45E
S42W
N5W
S38E
N29W
45T
222T
355T
142T
331T

Comments

There are no comments at the moment.