Table Coloring
Sam and his sister Sara have a table of n x m square cells. They want to color all of the cells in red or blue. Due to personal beliefs, they want every 2 x 2 square of the table have odd number of red cells (i.e. 1 or 3).
Unfortunately, last night, someone had colored some cells of the table with red and some of the others with blue. Sam and Saraare wondering whether they can color the rest of the table according to their rules or not. If it is possible, they want to know in how many ways they can color the table such that no 2 x 2 square contain an even number of red cells.
CONSTRAINTS
For each description of initially-colored cells, it is guaranteed that 1 <= x[i] <= n and 1 <= y[i] <= m.
Consider 2 <= n, m <= 10^5 and 0 <= k <= 10^5 for all test cases.
In 20% of tests n, m <=5 and k <=5.
In 50% of tests n, m <=5000 and k <=25.
Input
3 4 3
2 2 1
1 2 0
2 3 1Output
8 Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.