Hide

Problem D
Identifying Cells

Languages en sv

After receiving yet another Wrong Answer verdict, even though your program was guaranteed to be completely correct this time, you have decided to take a break from competitive programming. You are now studying biology instead, more specifically, you are interested in the cells of your favorite cactus (their green color reminds you of Accepted verdicts).

In the sample you are looking at, unfortunately, there are all sorts of cells, and it’s not entirely easy to know if you are really looking at your favorites. Different types of cells have different components that they can be identified by. For example, most cells have Golgi apparatuses, but only plant cells have vacuoles. Identification is further complicated by the fact that your cheap microscope doesn’t always manage to see all the components in a cell.

Your biology book describes the components of $N$ different cell types. There are a total of $K$ possible components, and no two cell types consist of exactly the same parts.

In order to aid your research, you will create a program that, given the components that you can see in a given cell, will attempt to identify its type. Because there are so many cells in your sample, it needs to do this $Q$ times.

Input

The first line of the input contains the integers $N$ and $K$ ($1 \leq N \leq 2 \cdot 10^5$, $1 \leq K \leq 21$), the number of cell types in your book and the number of possible components.

The following $N$ lines each describe a cell type from your book, the first line describing the first one, the second line describes the second one and so on. Each line contains a string containing $K$ ones or zeros, where the $i$:th character is a one if the cell type contains component $i$.

The next line contains a single integer $Q$ ($1 \leq Q \leq 2\cdot 10^5$), the number of queries.

The following $Q$ lines each describe a query. Each line contains a description of the components you can see in the microscope, in the same format as the cells in your book. A one in position $i$ means that you know that the cell you are looking at has component $i$. However, it may be the case that the cell contains more components that you can’t see with your microscope. Also note that it is possible that two different cells both have a certain component, but you are only able to see it in one of them.

Output

For each query, you should print a line containing the answer.

  • If the cell type can be decided unambiguously, print the index $1 \leq i \leq N$ of the type of the cell.

  • If there are multiple possibilites, you should print “vet ej” (don’t know).

  • If there are no matching cell types, you should print “finns ej” (doesn’t exist).

Scoring

Your solution will be tested on a set of test groups, each worth a number of points. Each test group contains a set of test cases. To get the points for a test group you need to solve all test cases in the test group.

Group

Points

Constraints

$1$

$15$

$ K \le 8$, $N, Q \leq 10$

$2$

$30$

$ N, Q \leq 1000$

$3$

$55$

No additional constraints.

Sample Input 1 Sample Output 1
3 4
1000
0110
1101
5
1000
1100
1001
0110
1010
vet ej
3
3
2
finns ej

Please log in to submit a solution to this problem

Log in