Let’s play a game. Given an initial number s0 and two sequences a1,a2,...,an, b1,b2,...,bn, you should get from s0 to 0 as fast as possible. On each step, you are allowed to pick an index i and apply the following operation on the current number:
sj+1=(sj⋅ai+bi)modm
This way, you’ll obtain the next number. You should find the minimum number of operations that would get you from s0 to 0.
Input
The first line of the input contains 3 integers n, m, and s0 (0 ≤ n ≤ 10, 0 ≤ m ≤ 100 000, and 0 < s0 < m).
The next n lines contain a pair of integers ai,bi (0 ≤ ai, bi ≤ 109).
Output
The program should print the minimum number of operations to get from s0 to 0. If it’s impossible to get to 0, the program should print Impossible.