2002 LSU Computer Science High School Programming Contest

Sponsored by Microsoft

Veteran - Problem 3

Fifty-Fifty (And Then Some)

There are times when Sam Slacker cannot decide on what to do--should he play a video game? Should he eat? Should he take a nap? At times like these, he can usually cut his choices down to two, but no further. And thus he turns to perhaps the most ancient tool of slack:

The coin.

Description:

Given a series of coin flips, with the results being either Heads (represented by a capital letter H) or Tails (represented by a capital letter T), you are to determine if the result of the series is closest to being All Heads, All Tails, Alternating, or Indeterminate. To determine the classification of a series, values for each classification (other than Indeterminate) must be, er, determined. This is done using the following method:

1. Start the count of All Heads, All Tails, and Indeterminate at zero.

2. Every time a flip comes out H, add one to the All Heads count.

3. Every time a flip comes out T, add one to the All Tails count.

4. Every time a flip causes a transition--either from H to T or T to H--add one to the Alternating count.

At the end of the series, if any one classification has a higher count than the others, that is the series' classification. If two or more tie for the highest count, then the series' classification is Indeterminate.

Input:

The first piece of data in the file is the number of series to calculate the classifications for, represented by a non-negative integer. For each series, the first piece of data is a non-negative integer n representing the number of coin flips in the series. The next n lines contain the results of the series of coin flips, with each line containing one character from the set {H, T}.

Output:

For each series, print

	Series x: All Heads
if the series' classification is All Heads, or
	Series x: All Tails
if the series' classification is All Tails, or
	Series x: Alternating
if the series' classification is Alternating, or
	Series x: Indeterminate
if the series' classification is Indeterminate. x is the series number, starting from 1.

Sample Input:

3		Number of series
10		Number of flips in the first series
H		First flip in the first series
T		Second flip in the first series
H
T
H
T
H
T
H
T		Tenth flip in the first series
10		Number of flips in the second series
H		First flip in the second series
T
T
H
H
T
T
H
H
T		Tenth flip in the second series
10		Number of flips in the third series
H		First flip in the third series
H
H
H
H
H
H
H
T
T		Tenth flip in the third series

Sample Output:

Series 1: Alternating
Series 2: Indeterminate
Series 3: All Heads