spoj#NSQUARE. NSquare Sum ( Easy )

NSquare Sum ( Easy )

Given two integers N ( N <= 10^18 ) and a prime number P ( 1 < P < 10^18 ), find the lowest number x such that there're not N integers greater or equal to 0 whose sum of squares is equal to x.

 

 

N = 2, P = 2

x = 3mod2 = 1

 

0 = 0² + 0²

1 = 1² + 0²

2 = 1² + 1²

4 = 2² + 0²

Input

There're two integers N ( 1 <= N <= 10^18 ) and a prime number P ( 1 < P < 10^18 ). You have to print the answer modulo P.

Output

You have to print an integer x mod P ( -1 < x < 10^18 + 1 ) that satisfies the problem. If there's no number x, print "Impossible".

Example

Input:
1 3

Output: 2

Input: 13 7

Output: Impossible

</p>