QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 256 MB Total points: 100 Hackable ✓

#11534. M(IT)+

统计

Busy Beaver is bored in class one day and decides to write several strings. He calls a string \textit{repetitive} if it is the character $\texttt{M}$ suffixed with one or more repetitions of $\texttt{IT}$. For example, the shortest repetitive strings are $\texttt{MIT}$, $\texttt{MITIT}$, $\texttt{MITITIT}$, ...

problem_11534_1.jpg

You are given a string $S$. Determine whether it can be expressed as the concatenation of one or more repetitive strings.

Input

The first line contains a single integer $T$ ($1 \leq T \leq 1000$)~--- the number of test cases.

The first line of each test case contains a single integer $|S|$ ($3 \leq |S| \leq 2 \cdot 10^5$)~--- the length of $S$.

The second line of each test case contains the string $S$ consisting of uppercase Latin characters.

The sum of $|S|$ over all test cases does not exceed $2 \cdot 10^5$.

Output

For each test case, output a single string “YES” or “NO” (without the quotes) denoting if the string $S$ is a concatenation of repetitive strings.

You can output YES and NO in any case (for example, strings yES, yes and Yes will be recognized as a positive response).

Example

Input

6
5
MITIT
4
MITI
15
MITITMITMITITIT
6
MITITM
9
MITBEAVER
5
MIIIT

Output

YES
NO
YES
NO
NO
NO

Explanation

In the first test case, the entire string $\tt{MITIT}$ is repetitive.

In the second test case, it can be shown that the string is not a concatenation of repetitive strings.

In the third test case, the string is the following concatenation of repetitive strings: $\texttt{MITIT} + \texttt{MIT} + \texttt{MITITIT}$.

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.