#1617 SequenceOfCommands

42  1 s   128 MB  

Description

You are standing on some arbitrary point in the infinite plane.

You are given a String commands that contains the commands you have to execute. Each character of commands is one command. The commands must be executed in the given order, one by one,

There are only three types of commands: 'S' means "step forward", 'L' means "turn 90 degrees to the left", and 'R' means "turn 90 degrees to the right". All your steps have the same length.

You will be executing the commands forever: after you execute the last character of commands, you will always start from the beginning again.

We say that your path is bounded if there is some positive real number R such that while executing the infinite sequence of steps you will never leave the circle with radius R steps and center at your starting location.

Given the String commands, your should determine whether your path will be bounded or not. Print the String "bounded" (hints for clarity) if the path is bounded and "unbounded" if it is not.

Input

The first line of the input gives the number of test cases, T (1 <= T <= 200).

For each test case, one string commands is given. Length of commands will be between 1 and 2500, inclusive, and each character of commands will be one of 'S', 'L', and 'R'.

Output

For each test case, print the result as explained in the problem statement, in one line.

Sample Input

Sample Output

4
L
SRSL
SSSSR
SRSLLLSSSSSSLSSSSSSL
bounded
unbounded
bounded
unbounded

HINT

For the first example, you are standing on the same spot forever, and in each step you take a turn 90 degrees to the left. This path is clearly bounded.

For the second example, imagine that you start executing the commands facing to the north. While following this sequence you will repeatedly execute the following steps: make a step to the north, rotate right, make a step to the east, and rotate left (to face north again). Given enough time, this path will take you arbitrarily far away from the spot where you started, hence it is unbounded.

For the third example, while executing this sequence of commands, you will be walking along the boundary of a small square.