题目描述
Biswa and Debu are playing a weird word game. Biswa has a set S of N strings. Debu makes Q turns. In each turn he gives Biswa a string T.
In each turn, Biswa's task is to find the longest substring of T which is also a substring in one of the strings in S.
Note: You can find the definition of substring here.
Input
The first line contains a single integer N
Next N lines describe the strings in S. Each line contains a single string
Next line contains a single integer Q
Next Q line contain one string each
Output
For each turn, you need to output a single integer which is the answer to that turn in a new line
Constraints
1 ≤ N ≤ 10^3
Sum of lengths of all the strings in S ≤ 2 * 10^5
1 ≤ Q ≤ 10^3
Sum of lengths of the strings over all turns ≤ 2 * 10^5
All the strings contain only lowercase English alphabets
SAMPLE INPUT
3
aaa
bbc
bac
3
aa
ccb
cba
SAMPLE OUTPUT
2
1
2
输入格式
见题面
输出格式
见题面