what is causing the TLE? it perfectly runs on online IDEs
def seive(m, N):
isprime = [True] * (N + 1)
primes = []
factors = [None] * (N + 1)
isprime[0] = isprime[1] = False
for i in range(2, N + 1):
if isprime[i] == True:
primes.append(i)
factors[i] = i
j = 0
while (j < len(primes) and i * primes[j] <= N and primes[j] <= factors[i]):
isprime[i * primes[j]] = False
factors[i * primes[j]] = primes[j]
j += 1
i = 0
while i < len(primes) and primes[i] <= n:
if primes[i] >= m:
print(primes[i], end = " ")
i += 1
t = int(input())
for x in range(t):
m, n = [int(a) for a in input().split()]
seive(m, n)
print()