11487 - Parentheses Matching   

Description

A string is said to be a SM string if it matches one of the following rules:

(1) An empty string is a SM string.

(2) If strings S1 and S2 are both SM strings, then S1S2 is SM string.

(3) If a string S is SM string, then {S}, [S], (S) and <S> are SM strings.

(4) If a string S is SM string, then "sm"S is a SM string.

Given a string consisting of parentheses, determine if it is a SM string.

Input

The input consists of several lines.

Each line contains a string S(1 <= |S| <= 10^6 ), where S consists of only '{', '}', '[', ']', '(', ')' and "sm".

Output

For each strings S, output "SM" if it is a SM string, "MS" if not.

There should be a '\n' in the end of each line.

Sample Input  Download

Sample Output  Download

Tags




Discuss