#P5491. 【模板】二次剩余
【模板】二次剩余
Description
Given , solve the equation
There are multiple test cases, and it is guaranteed that is an odd prime.
Input Format
Line contains an integer , which indicates the number of test cases.
Lines to each contain two integers and . Their meanings are described in the statement.
Output Format
Output a total of lines.
For each line of output, if there is a solution, output all solutions modulo in increasing order after taking . If the two solutions are the same, output only one of them. If there is no solution, output Hola!.
3
5 1000000009
4 1000000009
0 19260817
383008016 616991993
2 1000000007
0
Hint
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号