Problem list
Log in
#r03606 · CCC 2024 Senior

Heavy-Light Composition

Bronze II 2.0 s 256 MB

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$ and $N$, 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.

Example 1

Input
3 4
abcb
bcbb
babc
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.

Example 2

Input
2 3
abc
bcb
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.

Source
CCC 2024 Senior
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code