AT_arc227_d [ARC227D] Median of Binary Strings
Description
You are given length- $ M $ strings $ S_1,S_2,\ldots,S_N $ consisting of `0` and `1`.
Initially, $ S_1,S_2,\ldots,S_N $ are written on the blackboard.
You can perform the following operation zero or more times.
- Choose three strings from those written on the blackboard, allowing the same string to be chosen multiple times, and call them $ A,B,C $ . Newly write on the blackboard a string $ D $ of length $ M $ satisfying the following condition:
- For each $ i=1,2,\ldots,M $ , letting $ A_i,B_i,C_i,D_i $ denote the $ i $ -th characters of $ A,B,C,D $ , respectively, $ D_i $ is equal to at least two of $ A_i,B_i,C_i $ .
You are given $ Q $ strings $ T_1,T_2,\ldots,T_Q $ . For each $ i=1,2,\ldots,Q $ , determine whether it is possible to make $ T_i $ be written on the blackboard by performing operations starting from the initial state.
Input Format
The input is given from Standard Input in the following format:
> $ N $ $ M $ $ Q $ $ S_1 $ $ S_2 $ $ \vdots $ $ S_N $ $ T_1 $ $ T_2 $ $ \vdots $ $ T_Q $
Output Format
Output $ Q $ lines. The $ i $ -th line should contain `Yes` if $ T_i $ can be made to be written on the blackboard, and `No` otherwise.
Explanation/Hint
### Sample Explanation 1
$ T_1 $ is written on the blackboard from the beginning.
$ T_2 $ is `001`. If we perform the operation choosing the three strings `000`, `011`, `101`, we can newly write `001` on the blackboard.
### Sample Explanation 2
The strings initially written on the blackboard are both `0`, and the string newly written by the operation is also `0`. Therefore, it is impossible to make `1` be written on the blackboard.
### Constraints
- $ 1 \leq N \leq 500 $
- $ 1 \leq M \leq 500 $
- $ 1 \leq Q \leq 500 $
- $ S_i $ is a string of length $ M $ consisting of `0` and `1`. $ (1 \leq i \leq N) $
- $ T_i $ is a string of length $ M $ consisting of `0` and `1`. $ (1 \leq i \leq Q) $
- All input values are integers.