题目描述
Problem Description
In a string consisting only of lowercase letters, a letter is considered "heavy" if it appears more than once in the string, otherwise it is considered "light".
Given several strings, for each string, determine if the heavy and light letters alternate. (That is, either every odd-positioned letter is heavy and every even-positioned letter is light, or every odd-positioned letter is light and every even-positioned letter is heavy.)
Input Format
The first line of input contains two positive integers \( T \) and \( N \), representing the number of strings and the length of each string, respectively.
The next \( T \) lines each contain a string of length \( N \) consisting of lowercase letters.
Output Format
Output \( T \) lines, each containing a character T or F. If the \( i \)-th input string has alternating light and heavy letters, output T on the \( i \)-th line; otherwise, output F.
Sample Input and Output
Sample Input #1
3 4
abcb
bcbb
babc
Sample Output #1
T
F
T
Sample Input #2
2 3
abc
bcb
Sample Output #2
F
T
Notes
[Sample 1 Explanation]
The first string consists of light, heavy, light, heavy letters.
The second string ends with two consecutive heavy letters.
The third string consists of heavy, light, heavy, light letters.
[Sample 2 Explanation]
The first string consists entirely of light letters.
The second string consists of heavy, light, heavy letters.
[Data Range]
This problem uses batched testing.
For all data, it is guaranteed that the strings contain only lowercase letters, \( 2 \leq T \leq 10^4 \), and \( 2 \leq N \leq 100 \).
The following table shows the distribution of 15 points:
| Points | Range of \( T \) | Range of \( N \) | Additional Constraints |
|---|---|---|---|
| 5 | \( 2 \leq T \leq 4 \) | \( 2 \leq N \leq 4 \) | Strings only contain a and b |
| 5 | \( 2 \leq T \leq 10 \) | \( 2 \leq N \leq 30 \) | None |
| 2 | \( 2 \leq T \leq 100 \) | \( 2 \leq N \leq 100 \) | Only letter a is heavy; other letters are light |
| 3 | \( 2 \leq T \leq 10^4 \) | \( 2 \leq N \leq 100 \) | None |
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分