Regarding Pythagoreans challenge problem

My code works fine for given input but showing wrong answer when submitted.What is the error in my code??
import math
t=int(input())
l=[]
for i in range(t):
A=int(input())
l.append(A)
for k in l:
for j in range(k):
a=k-j**2

    if a>0:
        b=math.sqrt(a)
        if b-int(b)==0 and b>=j:
            p=(j,int(b))
            print(p,end=" ")
print()