Given a number $sum(1\leq sum \leq 100000000)$,we have $m$ queries which contains a pair ($x_i,y_i$) and would like to know the smallest nonnegative integer $k_{i}$ satisfying $x_i^{k_{i}}=y_i\ mod\ p$ when the prime number $p\ (sum\ mod\ p = 0)$(ps:$0^0=1$)
The first line contains a number T, indicating the number of test cases.
For each case, each case contains two integers $sum,m(1\leq sum\leq 100000000,1\leq m\leq 100000)$ in the first line.
The next $m$ lines will contains two intgeers $x_i,y_i(0\leq x_i,y_i\leq1000000000)$
For each test case,output "Case #$X$:" and $m$ lines.($X$ is the case number)
Each line cotain a integer which is the smallest integer for ($x_i,y_i$) ,if we can't find such a integer just output "-1" without quote.