#P14043. [SDCPC 2019] Flipping Game
[SDCPC 2019] Flipping Game
题目描述
Little Sub loves playing the game . In the game, lights, numbered from 1 to , are connected separately to switches. The lights may be either on or off initially, and pressing the -th switch will change the -th light to its opposite status (that is to say, if the -th light is on, it will be off after the -th switch is pressed, and vice versa).
The game is composed of exactly rounds, and in each round, the player must press exactly different switches. The goal of the game is to change the lights into their target status when the game ends.
Little Sub has just come across a very hard challenge and he cannot solve it. As his friend, it's your responsibility to find out how many solutions there are to solve the challenge and tell him the answer modulo .
We consider two solutions to be different if there exist two integers and such that , and the -th switch is pressed during the -th round of the first solution while it is not pressed during the -th round of the second solution, or vice versa.
输入格式
There are multiple test cases. The first line of the input contains an integer (about ), indicating the number of test cases. For each test case:
The first line contains three integers , , (, ).
The second line contains a string () consisting of only 0
and 1
, indicating the initial status of the lights. If the -th character is 1
, the -th light is initially on; If the -th character is 0
, the -th light is initially off.
The third line contains a string () consisting of only 0
and 1
, indicating the target status of the lights. If the -th character is 1
, the -th light must be on at the end of the game; If the -th character is 0
, the -th light must be off at the end of the game.
It is guaranteed that there won't be more than test cases that .
输出格式
For each test case output one line containing one integer, indicating the answer.
3
3 2 1
001
100
3 1 2
001
100
3 3 2
001
100
2
1
7
提示
For the first sample test case, Little Sub can press the -st switch in the -st round and the -rd switch in the -nd round; Or he can press the -rd switch in the -st round and the -st switch in the -nd round. So the answer is .
For the second sample test case, Little Sub can only press the -st and the -rd switch in the -st and only round. So the answer is .