#arc141b. [arc141_b]Increasing Prefix XOR
[arc141_b]Increasing Prefix XOR
Problem Statement
You are given positive integers and .
Find the number of sequences of positive integers that satisfy the following conditions, modulo .
- .
- , where .
Here, denotes bitwise .
What is bitwise ?
The bitwise of non-negative integers and , , is defined as follows:
- When is written in base two, the digit in the 's place () is if exactly one of and is , and otherwise.
For example, we have (in base two: ).
Generally, the bitwise of non-negative integers is defined as $(\\dots ((p_1 \\oplus p_2) \\oplus p_3) \\oplus \\dots \\oplus p_k)$. We can prove that this value does not depend on the order of .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
2 4
Sample Output 1
5
For example, counts, since and where .
The other pairs that count are $(A_1,\\ A_2)=(1,\\ 2),\\ (1,\\ 4),\\ (2,\\ 4),\\ (3,\\ 4)$.
Sample Input 2
4 4
Sample Output 2
0
Sample Input 3
10 123456789
Sample Output 3
205695670