Problem10218--CCC '24 S2 - Heavy-Light Composition

10218: CCC '24 S2 - Heavy-Light Composition

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 512 MiB

Description

In a string containing only lowercase letters of the alphabet (a through z), we say a letter is heavy if it appears more than once in the string, and light otherwise.

We will be given a number of strings. For each string, we would like to determine whether the letters of the string alternate between light and heavy.

Input

The first line of input will consist of two positive integers $T\ (2 \leq T \leq 10,000),\ N\ (2 \leq N \leq 100)$, representing the number of strings and the length of each string.

The next $T$ lines each contain a sequence of $N$ lowercase letters of the alphabet.

Output

Output $T$ lines, where each line will be either T or F. If the $i$-th input string does alternate between light and heavy letters, the $i$-th line of output should be T; and otherwise, the $i$-th line of output should be F.

Sample 1 Input

3 4
abcb
bcbb
babc

Sample 1 Output

T
F
T

The first string is composed of a light letter, then a heavy letter, then a light letter, and then a heavy letter.

The second string ends in two consecutive heavy letters.

The third string is composed of a heavy letter, then a light letter, then a heavy letter, and then a light letter.

Sample 2 Input

2 3
abc
bcb

Sample 2 Output

F
T

The first string is composed of all light letters.

The second string is composed of a heavy letter, then a light letter, and then a heavy letter.

HINT

CCC24S2

Source/Category