You suddenly remember part of a chorus of a song. You wonder which song has it in your list of song lyrics.
There are two parts in the input.
The first line of the first part of the input is an integer (1 \leq n \leq 15), the number of songs in your database. Then, you will be given strings in lines that only contain lowercase alphabets to .
Each string is a full lyric of a song without spaces, commas, periods, and any other non-lowercase alphabet characters. We have simplified this input format to avoid unnecessary errors.
We are using real songs in the test data, so you can expect that the length of the longest song in the list is less than characters.
Then, you will be given the second part of the input, which starts with another integer (1 \leq q \leq 20) that denotes the number of queries. Then, you will be given short strings in lines that only contain lowercase alphabets. Each query string is part of the song lyric, but not necessarily from the chorus.
Here we define the chorus of a song as the longest substring in that song lyric that appears more than once.
For each query string, output a list of song indices that have that query string in its chorus in one line. A query string is considered found in the chorus if it is a substring of the chorus. If more than one song is found, separate their indices by a single space.
Note: There must be no space at the end of the output, and song numbering starts from . If there is no song with such a chorus, output -1.
We guarantee that the output is unique.
Esempio 1
To check if your understanding of "chorus" is correct, here are the choruses (without the quotes) of the four songs in the sample input according to our definition.
Song , "thisisthechorus"
Song , "chorusishere"
Song , "chorus"
Song , "againitwasdestinysgameforwhenlovefinallycameonirushedinlineonlytofindthatyouweregone"
Songs , , and are dummy songs to help you understand this problem.
Song is a real song titled "Beautiful Girl", sung by Filipino "Jose Mari Chan". This song inspired this problem.