P5491 [Template] Quadratic Residue

Description

Given $N, p$, solve the equation $$ x^2 \equiv N \pmod{p} $$ There are multiple test cases, **and it is guaranteed that $p$ is an odd prime.**

Input Format

Line $1$ contains an integer $T$, which indicates the number of test cases. Lines $2$ to $T + 1$ each contain two integers $N$ and $p$. Their meanings are described in the statement.

Output Format

Output a total of $T$ lines. For each line of output, if there is a solution, output all solutions modulo $p$ in increasing order after taking $\bmod~ p$. If the two solutions are the same, output only one of them. If there is no solution, output `Hola!`.

Explanation/Hint

For $100\%$ of the testdata, $1 \le T \le 10^4$, $0 \le N, p \le 10^9 + 9$. Translated by ChatGPT 5