I was wondering if there is a way to solve this problem. Suppose we have x^2 = k mod m, and we know the values of k and m. Now, is it possible to find z such that x = z mod m from only k & m ?
P.S.: Sorry for not using latex. I don't know how to do it on codeforces.
If $$$m$$$ is prime, Tonelli-Shanks is a fast algorithm.