Basic Basis

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

You are given a sequence of nn bit strings b_1,b_2,,b_nb\_1, b\_2, \dots , b\_n, each with k×4k \times 4 bits.

You are also given another sequence of mm bit strings a_1,a_2,,a_ma\_1, a\_2, \dots , a\_m, each also with k× 4k \times 4 bits.

Let f(x)f(x) denote the minimum index ii such that it is possible to take a non-empty subset of b_1,b_2,,b_ib\_1, b\_2, \dots , b\_i , XOR them all together, and get xx. If there is no such index, f(x)=1f(x) = -1.

Print the values f(a_1),f(a_2),,f(a_m)f\left(a\_1\right), f\left(a\_2\right), \dots , f\left(a\_m\right).

입력

The first line of input contains three integers nn (1n1,0001 \le n \le 1,000), mm (1m1,0001 \le m \le 1,000) and kk (1k401 \le k \le 40), where nn is the length of sequence bb, mm is the length of sequence aa, and the elements of both sequences are bit strings with k×4k \times 4 bits.

Each of the next nn lines contains a hexadecimal representation of b_ib\_i as a string of length kk. The strings consist only of hexadecimal digits (‘0’–‘9’ and ‘a’–‘f’).

Then, each of the next mm lines contains a hexadecimal representation of a_ia\_i in the same format as above.

출력

Output mm lines with a single integer on each line, where the integer on the iith line is f(a_i)f\left(a\_i\right).