luogu#P5392. [Cnoi2019] 雪松树之约
[Cnoi2019] 雪松树之约
Background
Because Cirno suddenly became lazy, the background story is skipped.
Problem Description
Cirno defines a type of graph: the cylindrical network .
denotes a graph with nodes.
Each node is represented by an ordered pair of integers , where .
For , there is an edge between node and node .
For , there is an edge between node and node .
For , there is an edge between node and node .
Now Cirno wants to know the number of independent sets of .
Since you cannot do big integer arithmetic, you need to output the answer modulo .
Input Format
One line with two integers and .
Output Format
One line with one integer, the number of independent sets of modulo .
3 4
181
1000 8
124141757
Hint
For the first of the testdata, .
For the first of the testdata, .
For the first of the testdata, .
For of the testdata, .
This problem uses bundled tests.
The figure below is an example of .

Translated by ChatGPT 5