H. Hamburgers
time limit per test
3 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

In a city, there are several cafes that offer a wide range of various hamburgers.

Each hamburger, as well as the preferences of each customer, will be characterized by a list of additional ingredients that may be included in the hamburgers. Let's say a hamburger will please a customer if it contains all the ingredients that the customer likes. A customer will be satisfied with a cafe visit if there is a hamburger on the menu that they will enjoy.

Write a program to choose a cafe for a group of friends such that as many people from the group as possible are satisfied.

Input

The first line contains a single integer $$$n$$$ ($$$1 \leq n \leq 1\,000$$$) — the number of groups of friends.

Following this, there are $$$n$$$ blocks of data, each describing a group. The first line of each block contains a single non-negative integer $$$k_i$$$ — the number of people in the $$$i$$$-th group ($$$i = 1, 2, \ldots, n$$$). Next, each of the $$$k_i$$$ non-empty strings describes the preferences of a specific person in this group. Each string consists of at most $$$6$$$ distinct lowercase Latin letters, with each letter representing one of the $$$26$$$ possible additional ingredients.

The total number of people across all groups does not exceed $$$50\,000$$$.

Following this, there is a line containing a single integer $$$m$$$ ($$$1 \leq m \leq 1\,000$$$) — the number of cafes. Next, there are $$$m$$$ blocks of data, each describing a cafe. The first line of each block contains a single non-negative integer $$$l_j$$$ — the number of hamburgers on the menu of the $$$j$$$-th cafe ($$$j = 1, 2, \ldots, m$$$). Next, there are $$$l_j$$$ non-empty strings, each containing up to $$$6$$$ characters and describing the additional ingredients of the hamburgers in the format mentioned above.

The total number of hamburgers across all cafes does not exceed $$$50\,000$$$.

Output

For each group, output on a separate line a single integer from $$$1$$$ to $$$m$$$ — the number of the most suitable cafe. If there are multiple such cafes, output the minimum of these.

Example
Input
5
1
a
3
a
ba
cb
3
vba
d
ba
3
ca
da
da
3
as
ba
af
2
4
abc
abcd
a
a
2
abcdf
abcdv
Output
1
1
2
1
2