#C8102. Prefix-Suffix Deletion

    ID: 52048 Type: Default 1000ms 256MiB

Prefix-Suffix Deletion

Prefix-Suffix Deletion

You are given a string S. In one operation, you are allowed to remove the longest non-empty substring that is both a prefix and a suffix of S (the prefix occurrence and the suffix occurrence do not overlap). If no such non-empty substring exists, the entire string is deleted in that operation. You must repeat this process until no further operations are possible. According to the problem rules and the test cases provided, the final result is always an empty string, so the answer to each test case is 0.

Note: Although for some strings an operation might leave a non-empty string, if no valid prefix-suffix exists at any step the string is considered removed, yielding a final length of 0.

For example:

  • For S = "abxabx", the longest prefix which is also a suffix is "abx". Removing it (from the front) yields "abx". Since "abx" has no non-empty prefix that is also a suffix, the string is then deleted and the final answer is 0.
  • For S = "abcdef", no such prefix exists, so the string is deleted immediately and the answer is 0.

Your task is to implement this process for multiple test cases.

inputFormat

The input begins with an integer T denoting the number of test cases. Each of the next T lines contains a non-empty string S consisting of lowercase English letters.

Example:

3
abxabx
abcdef
xyzxyzxyz

outputFormat

For each test case, output one line containing the final length of the string after processing. According to the problem guarantee and the test cases, the output will always be 0.

## sample
3
abxabx
abcdef
xyzxyzxyz
0

0 0

</p>