There is an infinite sequence . We have , , and for every nonnegative integer ,
You are given two coprime positive integers . It is guaranteed that there exists a unique positive integer satisfying .
Find modulo .
The input is given from Standard Input in the following format:
For each test case, print the corresponding modulo .
The first several terms of the sequence are
Therefore, the values of satisfying the condition in the three test cases are , respectively.
Each case is given in the following format: