can this code be reduced to less time complexity
t=int(input())
for x in range(1,t+1):
n1, n2 = map(int,input().split())
for y in range(n1,n2+1):
if y==1:
continue
i=2
while i*i<=y:
if y%i==0:
break;
i=i+1
else:
print(y,end=" ")
print()