The formula of rocket distance as given in the problem description is (x2 - x1)2 + (y2 - y1)2, so for origin with coordinates (0,0), x1 and y1 must be 0. According to which the result of test case results should be 40 , 36 and 28 respectively.
Wrong formula for Rocket Distance
Hi Darpan mention problem link.
Hi
Why ??
consider test case:
Q=9 K=3;
1st query : 1 10 10 , so distance a hotel created at distance 200, ( 10^2+10^2)
2nd query 1 9 9, so distance a hotel created at distance 162
3rd query 1 -8 -8, so distance a hotel created at distance 128
4th query : 2 , so output is 3rd nearest hotel: so ans is 200
ans so on…
Hit Like if you get it! 
Cheers!
Hey. the doubt closed with no reply
Hi
you can see a reply above, or post your query if have more doubt