#P9393. 紫丁香
紫丁香
Problem Description
For a string , let denote its -th character.
Let be a string of length . We have operations. The -th operation can be represented as a function whose domain and codomain are both the set of length- strings, meaning that after this operation, becomes . The function can be described by a length- string , where consists of the three characters , and:
-
means .
-
means .
-
means .
That is, each operation sets some bits of to , some bits to , and leaves the remaining bits unchanged.
Now there are queries. In each query, you are given a length- string . You may apply the operations any number of times, in any order, and an operation may be used multiple times. The resulting string can be viewed as a binary number. Find the that corresponds to the maximum possible binary number.
Input Format
The first line contains three integers .
The next lines: each line contains a length- string , describing an operation.
The next lines: each line contains a length- string , describing a query.
Output Format
Output lines: each line contains a length- string, giving the answer to each query in order.
5 3 3
-1-01
011-0
--010
00000
10010
00101
01110
11010
01110
Hint
Sample Explanation
For the first query string , you can apply operations in order to obtain the optimal :
$$\texttt{00000}\to \texttt{00010}\to \texttt{01110}$$For the second query string , you can apply operations in order to obtain the optimal :
$$\texttt{10010}\to \texttt{11001}\to \texttt{11010}$$For the third query string , you can apply operations in order to obtain the optimal :
$$\texttt{00101}\to \texttt{00010}\to \texttt{01110}$$Constraints
For all testdata: , . contains only , and contains only .
| Subtask ID | Special Property | Score | |||
|---|---|---|---|---|---|
| None | |||||
| No in | |||||
| None | |||||

Translated by ChatGPT 5