The Remainder Game

Let’s play a game. Given an initial number s0s_0 and two sequences a1,a2,...,ana_1, a_2, ..., a_n, b1,b2,...,bnb_1, b_2, ..., b_n, you should get from s0s_0 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)mod  ms_{j+1} = (s_j \cdot a_i + b_i) \mod m

This way, you’ll obtain the next number. You should find the minimum number of operations that would get you from s0s_0 to 0.

Input

The first line of the input contains 3 integers n, m, and s0s_0 (0 ≤ n ≤ 10, 0 ≤ m ≤ 100 000, and 0 < s0s_0 < m).

The next n lines contain a pair of integers ai,bia_i, b_i (0 ≤ aia_i, bib_i ≤ 10910^9).

Output

The program should print the minimum number of operations to get from s0s_0 to 0. If it’s impossible to get to 0, the program should print Impossible.

Examples

Input

Output

2 5 1
3 1
2 1

2

Constraints

Time limit: 1.6 seconds

Memory limit: 512 MB

Output limit: 1 MB