Form guide#2542

Form guide

1 second
64 megabytes
Easy

"Form guide" is a type of sports statistic that shows how a team has performed recently, usually as the results of the last matches.

For example, if the results of the last matches (home and away) are:

H1-0

A0-0

H3-1

A0-1

A3-0

Here, the latest result is shown on the last line. Hx-y means a home match result, where is the team's score and is the opponent's score. Ay-x means an away match result, where the team's score is the second number.

For these results, the last-5 form of the team is:

Last-5

Overall Home Away

WDWWL WW DWL

where W = Win, D = Draw, and L = Loss.

You are to write a program that determines the team's last- match form from the results, as well as the longest winning streak (the number of consecutive wins in the overall results), the longest drawing streak (the number of consecutive draws), and the longest losing streak (number of consecutive losses). In the above example for last-5 results, the longest winning, drawing, and losing streaks for the overall results are , , , respectively.

Input

The first line of the input contains an integer , where 1 \leq n \leq 100 and is the number of team results. The following lines describe the results. In each line, the first character 'H' means home and 'A' means away, followed by the score: x-y for home matches and y-x for away matches, where is the team's score and is the opponent's score.

Output

Output lines: - The first line is the last- overall form (home and away), illustrated as a sequence of characters (W=Win, D=Draw, L=Loss), with the most recent match to the right. - The second line shows only home matches. - The third line shows only away matches. - Lines four to six are the longest winning streak, longest drawing streak, and longest losing streak in the overall results, respectively.

Examples

Example 1

Loading
Loading