My answer is correct in code blocks ide and jupyter notebook but when i sent the code it is showing timelimit error.
from math import sqrt
n = int(input())
for i in range(1,n+1):
A = int(input())
print()
for a in range(0,A+1):
for b in range(0,A+1):
try:
b1 = sqrt(A-(aa))
a1 = sqrt(A-(bb))
if (a<=b1 and b1==b) or (a1<=b and a1==a):
print("({},{})".format(a,b),end=" ")
except:
pass