시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 512 MB 8 3 3 37.500%

문제

You are given a sequence of $n$ bit strings $b_1, b_2, \dots , b_n$, each with $k \times 4$ bits.

You are also given another sequence of $m$ bit strings $a_1, a_2, \dots , a_m$, each also with $k \times 4$ bits.

Let $f(x)$ denote the minimum index $i$ such that it is possible to take a non-empty subset of $b_1, b_2, \dots , b_i$ , XOR them all together, and get $x$. If there is no such index, $f(x) = -1$.

Print the values $f\left(a_1\right), f\left(a_2\right), \dots , f\left(a_m\right)$.

입력

The first line of input contains three integers $n$ ($1 \le n \le 1,000$), $m$ ($1 \le m \le 1,000$) and $k$ ($1 \le k \le 40$), where $n$ is the length of sequence $b$, $m$ is the length of sequence $a$, and the elements of both sequences are bit strings with $k \times 4$ bits.

Each of the next $n$ lines contains a hexadecimal representation of $b_i$ as a string of length $k$. The strings consist only of hexadecimal digits (‘0’–‘9’ and ‘a’–‘f’).

Then, each of the next $m$ lines contains a hexadecimal representation of $a_i$ in the same format as above.

출력

Output $m$ lines with a single integer on each line, where the integer on the $i$th line is $f\left(a_i\right)$.

예제 입력 1

3 5 2
02
e1
fa
02
e3
1b
e1
ff

예제 출력 1

1
2
3
2
-1

예제 입력 2

5 6 2
01
02
04
08
10
01
02
03
04
05
64

예제 출력 2

1
2
2
3
3
-1