1072: Happy Robot

Memory Limit:128 MB Time Limit:1.000 S Judge Style:Text Compare Creator:
Submit:1 Solved:0

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 Input Copy

F?F
L??
LFFFRF

Sample Output Copy

Case 1: 1 3 -1 1
Case 2: -1 1 0 2
Case 3: 1 1 3 3