help-vaidy-to-impress-11

Vaidyanathan is walking on a sidewalk of a road, the road consists of W lanes and each lane consists of M spaces where at a moment of time, one space can be empty or it can be occupied by a vehicle . While walking on the sidewalk he sees a beautiful girl and tries to impress her somehow and he sees a small blind boy in the sidewalk who wants to cross the road of W lanes to the other side of the road ,that is, he wants to go to the other sidewalk of this road and join his group who are waiting for him.

So Vaidy says to the blind boy that he will help him cross the road and gets the attention of the girl and there comes the problem for Vaidy. The traffic in each lane is very high as it is a peak hour and the direction of the vehicles alternate between the lanes with the lane closest to his sidewalk has vehicles moving from left to right and the next lane has vehicles moving from right to left and so on. 

The vehicles never change their lane and move exactly only one step forward in their direction for each second. And to make sure that the traffic is steady .Once a vehicle in their lane moving in their direction reaches the end of their lane it wraps around to the opposite end of that lane. 

In each second the vehicles move forward by one step in their assigned lane direction. Now, coming to Vaidy, he can move freely in both the sidewalks either left or right by one step for one second as there will be no vehicles in the sidewalk. Vaidy cannot wrap around at the end of the lanes or sidewalk to the opposite end.

Vaidy and the vehicles in all lanes move simultaneously. Vaidy carries the small blind boy and for each second he can perform lane to lane movements or lane to sidewalk movements or sidewalk to lane movements ( up , down ) only if the space in that lane or sidewalk is empty and not occupied by a vehicle in that second and in his current sidewalk.

Vaidy cannot go down and in the other sidewalk where the blind boy's group is there he cannot go up. While Vaidy is in any lane in an empty space, he can also move left or right and jump over an approaching vehicle to that space of the lane in that second if there is no vehicle at that second in that space.

Vaidy can move to a space that there is no vehicle in that space in that lane in that second. And Vaidy can also choose to stay at the same space in that second in a lane if there is no vehicle in that space in the lane at that second. Each move and jump takes one second and don't forget the vehicles in all lanes and Vaidy move simultaneously.If at any second, Vaidy and a vehicle is at a same space in a lane, Vaidy and blind boy die. The girl has a time limit L after which she leaves. So, Vaidy wants to cross all the lanes without dying and help the blind boy within the time 
limit L as quick as possible in order to impress the girl more. 
Input format :

First line has number of test cases T 
Next line has two integers W and M 
where there will be W lanes and M spaces in each lane 
and the next line has a time limit L which denotes how long the girl will wait 
then there will be W+2 X M grid given to you the state map of this road and sidewalk 
where first line will be the other sidewalk where the blind boy's group is present 
and W+2 th line will be the sidewalk where vaidy, blind boy and the girl are present 
vehicles will be denoted by 'V', empty space denoted by '.' 
blind boy's position in the sidewalk will be denoted by 'B' in the W+2 th line 
blind boy's group in the other sidewalk will be denoted by 'G' in the first line 
Input Constraints :

1 ≤ T ≤ 10 in one input file 
1 ≤ W ≤ 20 
1 ≤ M ≤ 50 
0 ≤ L ≤ 10^5 
W+2 lines each of size M, 
exactly one 'G' in first line and exactly one B in W+2 th line 
rest all will be 'V' or '.' . 
Output format :

for each and every test case output in separate line, 
"SOUP BOY." (without quotes) if it is not possible for vaidy to help the blind boy within L or he dies. 
"SUCCESS IN answer SECOND(S)." (without quotes) if it is possible for vaidy to help the blind boy cross the road in answer second(s). 
where answer here is the result for minimum number of second(s) it will take for Vaidy to help blind boy cross the road within L. 

SAMPLE INPUT
2
2 4
20
...G
V.VV
.V.V
.B..
1 1
100
G
V
B

SAMPLE OUTPUT
SUCCESS IN 5 SECOND(S).
SOUP BOY.

Explanation

In first case vaidy moves right , up , up , up , right.
So answer is 5 seconds.
In second case vaidy can only move up now but if he moves he will die along with the boy so he becomes a SOUP BOY.

Source: hackerearth | Difficulty: UNKNOWN_DIFFICULTY


Solutions: