#P4424. [HNOI/AHOI2018] 寻宝游戏

    ID: 3360 远端评测题 1000ms 500MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>2018各省省选安徽湖南排序进制位运算,按位

[HNOI/AHOI2018] 寻宝游戏

Description

At a certain university, there is an annual Mystery Hunt. Players must solve puzzles using given clues to find the treasure, and the previous year's winning team earns the right to write the problems for the current year.

As a freshman, you are very interested in this event. Every day you walk from west to east through a very long corridor in the teaching building. The corridor is so long that people jokingly call it the "infinite corridor." One day, as you pass through the corridor, you notice that there are nn hidden binary numbers of equal length on the corridor wall, all of length mm. You record these numbers from west to east, forming a binary array of nn numbers a1,a2,...,ana_1,a_2,...,a_n.

Soon, in the latest issue of the Voo Doo magazine, you discover qq binary numbers of length mm, namely r1,r2,...,rqr_1,r_2,...,r_q.

You quickly figure out the meaning of these numbers.

Keeping the order of the array a1,a2,...,ana_1,a_2,...,a_n unchanged, you may insert \land (bitwise AND) or \lor (bitwise OR) between them. For example: 1101100111=0001111011\land 00111=00011, 1101100111=1111111011\lor 00111=11111.

You need to insert nn operators: exactly one between each pair of adjacent numbers, and one more to the left of the first number. If we put a 00 to the left of the first operator, this forms an expression whose value we can compute. As usual, the evaluation order is from left to right. Interestingly, the setter has already told you the possible set of resulting values — the binary numbers r1,r2,...,rqr_1,r_2,...,r_q in the Voo Doo magazine. The way to solve the puzzle is: for each value rir_i among r1,r2,...,rqr_1,r_2,...,r_q, compute how many ways there are to fill in these nn operators so that the expression evaluates to rir_i.

However, the infinite corridor is truly long, which means the ranges may be very large. Therefore, the answers may also be very large, but due to the special nature of the puzzle, you only need to output the answers modulo 10000000071000000007.

Input Format

The first line contains three integers n,m,qn,m,q, as described.

The next nn lines: the ii-th line contains a binary number of length mm, with the most significant bit on the left, representing aia_i.

The next qq lines: the ii-th line contains a binary number of length mm, with the most significant bit on the left, representing rir_i.

Output Format

Output qq lines, one integer per line. The ii-th line is the answer for rir_i.

5 5 1
01110
11011
10000
01010
00100
00100
6
10 10 3
0100011011
0110100101
1100010100
0111000110
1100011110
0001110100
0001101110
0110100001
1110001010
0010011101
0110011111
1101001010
0010001001
69
0
5

Hint

Constraints:

  • For 10%10\% of the testdata, n20n \le 20, m30m \le 30, q=1q = 1.
  • For an additional 20%20\% of the testdata, n1000n \le 1000, m16m \le 16.
  • For an additional 40%40\% of the testdata, n500n \le 500, m1000m \le 1000.
  • For all testdata, 1n10001 \le n \le 1000, 1m50001 \le m \le 5000, 1q10001 \le q \le 1000.

Translated by ChatGPT 5