#P3734. [HAOI2017] 方案数
[HAOI2017] 方案数
Description
Define a relation on non-negative integers: if , then , where denotes the bitwise AND.
Consider an infinite space. You start at , and you have three types of moves:
- if .
- if .
- if .
Due to a mysterious force, some points are blocked, i.e., you cannot pass through them. Find the number of ways to reach the point . Output the answer modulo .
Input Format
The first line contains three integers .
The next line contains a single integer , the number of obstacles.
Each of the next lines contains three integers giving the coordinates of an obstacle, where , , . No obstacle is at or , and obstacles are pairwise distinct.
Output Format
Output a single integer, the required answer.
1 1 1
0
6
Hint
[Sample explanation]
There are 8 states: , , , , , , , . The corresponding numbers of ways are .
[Constraints]
- For of the testdata: .
- For of the testdata: .
- For another of the testdata: .
- For of the testdata: , .
Translated by ChatGPT 5
京公网安备 11011102002149号