from math import *
prime = [1] * (10 ** 6 + 1 )
def sang():
prime[0] = 0
prime[1] = 0
for i in range(2 , isqrt((10 ** 6 + 1 )) + 1):
if(prime[i]):
for j in range(i * i , (10 ** 6 + 1 ), i):
prime[j] = 0
if __name__ == '__main__':
sang()
F = [0] * (10 ** 6 + 1 )
F[0] = 0
F[1] = 0
tich = 1
for i in range(2 , (10 ** 6 + 1 )):
if(prime[i]):
tich *= i
tich %= (10 ** 9 + 7)
F[i] = tich
F[i] %= (10 ** 9 + 7)
t = int(input())
for i in range(t):
n = int(input())
print(F[n])
ZnJvbSBtYXRoIGltcG9ydCAqCnByaW1lID0gWzFdICogKDEwICoqIDYgKyAxICkKZGVmIHNhbmcoKToKICAgIHByaW1lWzBdID0gMAogICAgcHJpbWVbMV0gPSAwCiAgICBmb3IgaSBpbiByYW5nZSgyICwgaXNxcnQoKDEwICoqIDYgKyAxICkpICsgMSk6CiAgICAgICAgaWYocHJpbWVbaV0pOgogICAgICAgICAgICBmb3IgaiBpbiByYW5nZShpICogaSAsICgxMCAqKiA2ICsgMSApLCBpKToKICAgICAgICAgICAgICAgIHByaW1lW2pdID0gMAoKaWYgX19uYW1lX18gPT0gJ19fbWFpbl9fJzoKICAgIHNhbmcoKQogICAgRiA9IFswXSAqICgxMCAqKiA2ICsgMSApCiAgICBGWzBdID0gMAogICAgRlsxXSA9IDAKICAgIHRpY2ggPSAxCiAgICBmb3IgaSBpbiByYW5nZSgyICwgKDEwICoqIDYgKyAxICkpOgogICAgICAgIGlmKHByaW1lW2ldKToKICAgICAgICAgICAgdGljaCAqPSBpCiAgICAgICAgICAgIHRpY2ggJT0gKDEwICoqIDkgKyA3KQogICAgICAgIEZbaV0gPSB0aWNoCiAgICAgICAgRltpXSAlPSAoMTAgKiogOSArIDcpCiAgICB0ID0gaW50KGlucHV0KCkpCiAgICBmb3IgaSBpbiByYW5nZSh0KToKICAgICAgICBuID0gaW50KGlucHV0KCkpCiAgICAgICAgcHJpbnQoRltuXSkKCg==