CSG-CPC
Online Judge

1130 : Happy Robot

         Time Limit: 1 Sec     Memory Limit: 128 MB     Submitted: 38     Solved: 19    

Description

A robot is moving from (0,0) according to a command sequence. Each character in the sequence is command:

  • L: turn left
  • R: turn right
  • F: go forward one step

Interestingly, the command sequence contains some wildcard character “?”. The robot can treat it any one of L, R or F at its own wish, which makes it really happy.

Let (x,y) be the final position of the robot, your task is to find out the minimal/maximal possible value of x and y. Initially the robot is facing east (i.e. facing (1,0) in Cartesian coordinate system). After a left turn it will face north (i.e. facing (0,1)).

Input

There will be at most 1000 test cases. Each case contains a command sequence with no more than 1000 characters.

Output

For each test case, print the case number, followed by minimal/maximal possible x (in this order), then the minimal/maximal possible y.

Sample

F?F
L??
LFFFRF
Case 1: 1 3 -1 1
Case 2: -1 1 0 2
Case 3: 1 1 3 3

Hint

Author

SRbGa