drunk-man
Source: hackerearth
Difficulty: UNKNOWN_DIFFICULTY

A drunk person was moving from one point on the street to another point on the same street. His starting point was between two manholes on that street. He was following a systematic scheme of his movement and had a fix movement repeated after an interval of time. How much time will he take to fall in the manhole and in which manhole will he fall in.

input 

The first line should contain number of test cases 'N' 
Next 'N' lines should have space separated inputs 'B' or 'F' which will depict the first movement of the drunk person in backward or forward direction respectively next five space separated numbers depict the distance of the hole in forward direction in meters distance of the hole in backward direction in meters forward steps in meters backward step in meters and time taken to complete 1 meter respectively

output 

In a single line print the manhole in which he will fall ‘F’ for the manhole that is in forward direction and ‘B’ for the manhole in backward direction followed by the time that he took to fall in that manhole and if he will not fall in any of the manhole then print 'SURVIVED'.

SAMPLE INPUT
4
F 10 10 4 3 1
B 10 10 3 4 2
F 15 10 3 5 4
F 19 12 3 3 2

SAMPLE OUTPUT
F46
B92
B160
SURVIVED