#arc144d. [arc144_d]AND OR Equation
[arc144_d]AND OR Equation
Problem Statement
You are given positive integers and . Find the number, modulo , of integer sequences that satisfy all of the following conditions:
- for all non-negative integers ().
- $f(x) + f(y) = f(x \\,\\mathrm{AND}\\, y) + f(x \\,\\mathrm{OR}\\, y)$ for all non-negative integers and ()
Here, and denote the bitwise AND and OR, respectively.
Constraints
Input
Input is given from Standard Input in the following format:
Output
Print the number, modulo , of integer sequences that satisfy the conditions.
Sample Input 1
2 1
Sample Output 1
6
The following six integer sequences satisfy the conditions:
Sample Input 2
2 2
Sample Output 2
19
Sample Input 3
100 123456789123456789
Sample Output 3
34663745