Form Guide

No attempts yetTime limit1sMemory limit128 MB

Problem

A form guide is a sport statistic that shows how well a team has been playing lately. It usually lists the results of the last n matches as a string of win, draw and loss marks.

Each result line starts with H for a home match or A for an away match. After that first character come two scores joined by a hyphen. In a home result Hx-y, the first number x is our team's score and the second number y is the opponent's score. In an away result Ay-x the order is reversed, so the first number y is the opponent's score and the second number x is our team's score. Our team's score is the first number at home and the second number away.

A match is a win (W) when our team scored more, a draw (D) when both scores are equal, and a loss (L) when our team scored less.

The results are given oldest first. Build the form string over all matches, over home matches only and over away matches only, then find the longest run of consecutive wins, the longest run of consecutive draws and the longest run of consecutive losses in the overall form.

Input

The first line contains the number of matches n (1n1001 \le n \le 100). Each of the next n lines holds one result, oldest first. A line starts with H for a home match or A for an away match, followed by two scores joined by a hyphen: Hx-y for a home match and Ay-x for an away match, where x is our team's score and y is the opponent's score. Every score is a nonnegative integer.

Output

Print six lines.

  1. The form string over all matches, with the oldest match on the left and the most recent one on the right.
  2. The form string over home matches only.
  3. The form string over away matches only.
  4. The longest run of consecutive wins in the overall form.
  5. The longest run of consecutive draws in the overall form.
  6. The longest run of consecutive losses in the overall form.

Print an empty line when no match belongs to that group, and print 0 when the run in question never occurs.