In the first line there is an integer T (T<=20) – the number of different maps. For each map in first line there is an integer N (N<=1000) – the number of corridors. It is known that no two vertical corridors have common point and no two horizontal corridors have common point.
So the next N lines contain such information: the line starts with one of the characters V or H – vertical or horizontal corridor. Then one Y-coordinate and two X-coordinates are given for a horizontal corridor or one X-coordinate and two Y-coordinates for a vertical corridor. The last line for each map contains X and Y coordinates of the entry point (start and end point of travel) and the direction (W – left, E – right, N – up and S – down). You may assume that: entry point is not located in the cross-point of two corridors, and explorer can always moves forward by the direction given in the input. All coordinates are integers and do not exceed 32767 by absolute value and there is no more than 500 vertical corridors and no more than 500 horizontal corridors.