#arc071d. [arc071_d]Infinite Sequence
[arc071_d]Infinite Sequence
Problem Statement
How many infinite sequences consisting of {} satisfy the following conditions?
- The -th and subsequent elements are all equal. That is, if , .
- For every integer , the elements immediately following the -th element are all equal. That is, if , .
Find the count modulo .
Constraints
Input
Input is given from Standard Input in the following format:
Output
Print how many sequences satisfy the conditions, modulo .
Sample Input 1
2
Sample Output 1
4
The four sequences that satisfy the conditions are:
Sample Input 2
654321
Sample Output 2
968545283