Passwords

No attempts yetTime limit7sMemory limit128 MB

Problem

The secret server of ICPC (Inter-Continental Programming Company) uses two passwords vv and ww. The two strings satisfy vw=wvv^{|w|} = w^{|v|}, which means that vv concatenated w|w| times and ww concatenated v|v| times give the same string, where v|v| is the length of the string vv. For example, with v=abv = \mathtt{ab} and w=ababw = \mathtt{abab} you get v4=w2=ababababv^{4} = w^{2} = \mathtt{abababab}. The trivial case v=wv = w is not secure, so it is never used.

The two strings are hard to memorize, so the administrator hid them in a set of nn strings. The set contains two distinct strings xx and yy such that vv is a prefix of xx (x=vvx = vv') and ww is a suffix of yy (y=wwy = w'w).

Given the set of strings, write a program that finds the password pair.

Input

Your program reads from standard input. The first line contains the number of test cases TT.

Each test case begins with a line containing nn, the number of strings in the set. (2n2002 \le n \le 200)

Each of the next nn lines contains one string. Every string consists of lowercase English letters and its length is at most 20,00020{,}000.

Output

Your program writes to standard output. Print exactly one line for each test case.

Each line contains two integers v|v| and w|w|, where two distinct strings xx and yy of the set satisfy that vv is a prefix of xx, ww is a suffix of yy, vw=wvv^{|w|} = w^{|v|} and v<w|v| < |w|. If two or more such pairs exist, print the one whose v+w|v| + |w| is the greatest. Such a password pair is unique whenever it exists. If there is no such pair, print 0 0.