AT_abc475_e [ABC475E] Quiz Competition: Qualifiers
Description
A preliminary round of a quiz competition was held. There are $ N $ participants, numbered $ 1 $ to $ N $ , and at most $ M $ of them can pass the preliminary round.
The preliminary round consists of $ K $ two-choice quiz questions, and the answer to each question is `o` or `x`.
Participant $ i $ 's answer to the $ j $ -th question is given as the $ j $ -th character of the string $ S_i $ .
The correct answer to the $ j $ -th question is given as the $ j $ -th character of the string $ T $ .
The qualifiers are determined by the following procedure.
- Initially, the numbers of qualifiers and non-qualifiers are both $ 0 $ ; all $ N $ participants are undetermined.
- For $ k=1,2,\dots,K $ in this order, perform the following process.
- If the number of qualifiers plus the number of undetermined participants who answered the $ k $ -th question correctly is at most $ M $ , then all undetermined participants who answered the $ k $ -th question correctly become qualifiers.
- Otherwise, all undetermined participants who answered the $ k $ -th question incorrectly become non-qualifiers.
- All remaining undetermined participants become non-qualifiers.
You are given $ Q $ queries in the following format. Process them in order.
- Integers $ i $ and $ j $ are given. Change participant $ i $ 's answer to the $ j $ -th question from `o` to `x`, or from `x` to `o`. Then, determine whether participant $ i $ passes the preliminary round.
The change of the answer in each query remains in effect when processing subsequent queries as well.
Input Format
The input is given from Standard Input in the following format:
> $ N $ $ M $ $ K $ $ T $ $ S_1 $ $ \vdots $ $ S_N $ $ Q $ $ \mathrm{query}_1 $ $ \vdots $ $ \mathrm{query}_Q $
Here, $ \mathrm{query}_q $ represents the $ q $ -th query, and is given in the following format:
> $ i $ $ j $
Output Format
Output $ Q $ lines.
The $ q $ -th line should contain `Yes` if the participant specified in the $ q $ -th query passes the preliminary round, and `No` otherwise.
Explanation/Hint
### Sample Explanation 1
- Before the first query, participants $ 1,2 $ pass on the first question and participant $ 3 $ passes on the second question, so the qualifiers are the three participants $ 1,2,3 $ .
- After the first query, participants $ 1,2,5 $ pass on the first question, so the qualifiers are the three participants $ 1,2,5 $ . Since participant $ 5 $ passes the preliminary round, output `Yes`.
- After the second query, participants $ 1,2,5 $ still pass on the first question, so the qualifiers are the three participants $ 1,2,5 $ . Since participant $ 1 $ passes the preliminary round, output `Yes`.
- After the third query, participant $ 3 $ is eliminated on the first question, participants $ 1,2 $ pass on the second question, and participant $ 5 $ passes on the third question, so the qualifiers remain the three participants $ 1,2,5 $ . Since participant $ 4 $ does not pass the preliminary round, output `No`.
### Constraints
- $ 1 \leq M \leq N \leq 3\times 10^4 $
- $ 1 \leq K \leq 200 $
- $ S_i $ and $ T $ are strings of length $ K $ consisting of `o` and `x`.
- $ 1 \leq Q \leq 5\times 10^4 $
- For each query, $ 1\leq i \leq N $ and $ 1 \leq j \leq K $ .