D. Double Strings
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
You are given nn strings s1,s2,…,sns1,s2,…,sn of length at most 88.
For each string sisi, determine if there exist two strings sjsj and sksk such that si=sj+sksi=sj+sk. That is, sisi is the concatenation of sjsj and sksk. Note that jj can be equal to kk.
Recall that the concatenation of strings ss and tt is s+t=s1s2…spt1t2…tqs+t=s1s2…spt1t2…tq, where pp and qq are the lengths of strings ss and tt respectively. For example, concatenation of "code" and "forces" is "codeforces".
Input
The first line contains a single integer tt (1≤t≤1041≤t≤104) — the number of test cases.
The first line of each test case contains a single integer nn (1≤n≤1051≤n≤105) — the number of strings.
Then nn lines