I have tried this code
p = 1000003
q = 400003
M = p*q
n = 84480
X = [6225**2%M]
new = X[0]**2%M
i = 1
while new not in X and len(X) < n:
X.append(new)
new = X[i]**2%M
i += 1
.append syntax took a while to build the list. I need another syntax to make a list faster because n is quite large.