Positive integer $x$ is called divisor of positive integer $y$, if $y$ is divisible by $x$ without remainder. For example, $1$ is a divisor of $7$ and $3$ is not divisor of $8$.

We gave you an integer $d$ and asked you to find the smallest positive integer $a$, such that

$a$ has at least $4$ divisors;

difference between any two divisors of $a$ is at least $d$.


-----Input-----

The first line contains a single integer $t$ ($1 \leq t \leq 3000$) — the number of test cases.

The first line of each test case contains a single integer $d$ ($1 \leq d \leq 10000$).


-----Output-----

For each test case print one integer $a$ — the answer for this test case.


-----Examples-----

Input
2
1
2
Output
6
15


-----Note-----

In the first test case, integer $6$ have following divisors: $[1, 2, 3, 6]$. There are $4$ of them and the difference between any two of them is at least $1$. There is no smaller integer with at least $4$ divisors.

In the second test case, integer $15$ have following divisors: $[1, 3, 5, 15]$. There are $4$ of them and the difference between any two of them is at least $2$.

The answer $12$ is INVALID because divisors are $[1, 2, 3, 4, 6, 12]$. And the difference between, for example, divisors $2$ and $3$ is less than $d=2$.

Source: codeforces | Difficulty: EASY
Tags: Constructive algorithms

Sorting

Greedy algorithms

Number theory

Mathematics


Solutions:
dp = [True] * 100001
dp[0] = False
dp[1] = False
p = 2
import bisect
while p * p <= 100001:
	if dp[p] == True:
		for i in range(p * p, 100001, p):
			dp[i] = False
	p += 1
prime = []
for i in range(2, 100001):
	if dp[i]:
		prime.append(i)
del dp
for t in range(int(input())):
	d = int(input())
	if d == 1:
		print(6)
		continue
	if d == 2:
		print(15)
	else:
		fl = False
		fl2 = False
		l1 = 0
		l2 = 0
		l1 = bisect.bisect_left(prime, d + 1)
		l2 = bisect.bisect_left(prime, prime[l1] + d)
		print(prime[l1] * prime[l2])


import math
t = int(input())

def findPrime(i):
	while True:
		prime = True
		for j in range(2, math.floor(math.sqrt(i)) + 1):
			if i % j == 0:
				prime = False
				break
		if prime:
			return i
		i += 1
while t > 0:
	t -= 1
	n = int(input())
	tmp = 1 + n
	d1 = findPrime(tmp)
	d2 = findPrime(n + d1)
	print(d1 * d2)


import math
for _ in range(int(input())):
	d = int(input())
	x = d
	x += 1
	if d == 1:
		print('6')
	else:
		while True:
			ok = True
			for i in range(2, math.floor(math.sqrt(x)) + 1):
				if x % i == 0:
					ok = False
					x += 1
					break
			if ok == True:
				z = x
				break
		x += d
		while True:
			ok = True
			for i in range(2, math.floor(math.sqrt(x)) + 1):
				if x % i == 0:
					ok = False
					x += 1
					break
			if ok == True:
				zz = x
				break
		print(z * zz)


from math import sqrt

def prime(x):
	flag = True
	for i in range(2, int(sqrt(x)) + 1):
		if x % i == 0:
			flag = False
			break
	return flag
arr = []
for i in range(2, 25001):
	if prime(i):
		arr.append(i)
ans = []
pos1 = 0
pos2 = 0
d = 1
while d <= 10000:
	while arr[pos1] - 1 < d:
		pos1 += 1
	while arr[pos2] - arr[pos1] < d:
		pos2 += 1
	ans.append(arr[pos1] * arr[pos2])
	d += 1
t = int(input())
for i in range(t):
	n = int(input())
	print(ans[n - 1])


primes = set()
for i in range(2, 20400):
	primes.add(i)
for div in range(2, 20400):
	j = 2 * div
	while j <= 20400:
		if j in primes:
			primes.remove(j)
		j += div

def isprime(i):
	return i in primes
for _ in range(int(input())):
	d = int(input())
	p1 = -1
	for num in range(d + 1, d + 1000):
		if isprime(num):
			p1 = num
			break
	p2 = -1
	for num in range(p1 + d, p1 + d + 1000):
		if isprime(num):
			p2 = num
			break
	print(p1 * p2)


def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def nextp(n):
	while True:
		n += 1
		if isPrime(n):
			return n
for _ in range(int(input())):
	n = int(input())
	number = nextp(n)
	print(number * nextp(number + n - 1))


def primesBelow(n):
	limit = n
	primes = [True] * limit
	primes[0] = False
	primes[1] = False
	testprime = 2
	while testprime * testprime < limit:
		for i in range(testprime * testprime, limit, testprime):
			primes[i] = False
		for j in range(testprime + 1, limit):
			if primes[j] == True:
				testprime = j
				break
	finalprimes = []
	for k in range(limit):
		if primes[k]:
			finalprimes.append(k)
	return finalprimes
primes = primesBelow(500000)
t = int(input())
for _ in range(t):
	d = int(input())
	for p in primes:
		if p >= 1 + d:
			firstPrime = p
			break
	for p in primes:
		if p >= firstPrime + d:
			secondPrime = p
			break
	print(firstPrime * secondPrime)


I = input
N = 8 ** 5
a = [1] * N
i = 2
while (j := (i * i)) < N:
	if a[i]:
		a[j::i] = [0] * ((N - j - 1) // i + 1)
	i += 1
for _ in range(int(I())):
	d = int(I())
	i = a.index(1, d + 1)
	print(i * a.index(1, i + d))


from bisect import bisect_left
Primes = [True] * 100001
Primes[0] = Primes[1] = False
for I in range(100001):
	if Primes[I]:
		M = 2
		while M * I <= 100000:
			Primes[M * I] = False
			M += 1
ListPrimes = []
for (I, P) in enumerate(Primes):
	if P:
		ListPrimes.append(I)
T = int(input().strip())
for _ in range(T):
	D = int(input().strip())
	P1 = ListPrimes[bisect_left(ListPrimes, 1 + D)]
	P2 = ListPrimes[bisect_left(ListPrimes, P1 + D)]
	print(P1 * P2)


def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
for testis in range(int(input())):
	d = int(input())
	i = d + 1
	while True:
		if isPrime(i):
			a1 = i
			break
		else:
			i = i + 1
	j = a1 + d
	while True:
		if isPrime(j):
			a2 = j
			break
		else:
			j = j + 1
	print(a1 * a2)


from functools import lru_cache
prime = [True for i in range(100000 + 1)]

def SieveOfEratosthenes(n):
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1

@lru_cache(None)
def getPrime(n):
	if n == 2:
		return 2
	while True:
		if prime[n] == True:
			return n
		n = n + 1
SieveOfEratosthenes(10 ** 5)
t = int(input())
for i in range(t):
	d = int(input())
	a1 = getPrime(1 + d)
	a2 = getPrime(a1 + d)
	print(a1 * a2)


def psieve(n):
	result = [True] * (n + 1)
	for k in range(2, n + 1):
		if result[k]:
			result[2 * k::k] = [False] * (n // k - 1)
	result[0] = False
	result[1] = False
	return result
Primes = psieve(21000)
t = int(input().strip())
for _ in range(t):
	d = int(input().strip())
	r = 1
	P = 1 + d
	while not Primes[P]:
		P += 1
	r *= P
	P += d
	while not Primes[P]:
		P += 1
	print(r * P)


import sys
input = sys.stdin.readline
import math
import bisect
all_primes = [2, 3, 5, 7, 11, 13, 17, 19, 23]
for i in range(24, 22000):
	for p in all_primes:
		if p > math.sqrt(i) + 2:
			all_primes.append(i)
			break
		elif i % p == 0:
			break

def solution(d, all_primes):
	factors = [1]
	for _ in range(2):
		val = factors[-1] + d
		pos = bisect.bisect_left(all_primes, val)
		factors.append(all_primes[pos])
	print(factors[-2] * factors[-1])
T = int(input())
for t in range(T):
	d = int(input())
	solution(d, all_primes)


import sys, os, io
import math, bisect, operator
(inf, mod) = (float('inf'), 10 ** 9 + 7)
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, defaultdict
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
Neo = lambda : list(map(int, input().split()))

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	Ans = []
	for p in range(2, n + 1):
		if prime[p]:
			Ans.append(p)
	return Ans
Ans = SieveOfEratosthenes(100000)
t = len(Ans)
for _ in range(int(input())):
	d = int(input())
	a = Ans[min(bisect.bisect_left(Ans, 1 + d), t - 1)]
	b = Ans[min(bisect.bisect_left(Ans, a + d), t - 1)]
	print(a * b)


def isp(n):
	if n <= 1:
		return False
	for i in range(2, n):
		if n % i == 0:
			return False
	return True
for _ in range(int(input())):
	l = 0
	d = int(input())
	k = [1]
	u = 1 + d
	while l < 2:
		if isp(u):
			k.append(u)
			u += d
			l += 1
		else:
			u += 1
	c = 1
	for i in k:
		c *= i
	print(c)


from sys import stdin
t = int(stdin.readline())
primes = [0] * 10 ** 5
primes[0] = 1
primes[1] = 1

def pri():
	for i in range(2, 10 ** 5):
		if primes[i] == 0:
			for j in range(2 * i, 10 ** 5, i):
				primes[j] = 1

def search(n):
	i = n
	while primes[i] != 0:
		i += 1
	return i
pri()
for _ in range(t):
	n = int(stdin.readline())
	p = search(n + 1)
	q = search(p + n)
	print(p * q)


from math import sqrt

def isprime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def next_prime(n, step):
	n = n + step
	while isprime(n) == False:
		n += 1
	return n
for _ in range(int(input())):
	n = int(input())
	a = next_prime(1, n)
	b = next_prime(a, n)
	print(a * b)


prime = [1] * 30000
for p in range(2, 30000):
	if prime[p] == 1:
		for i in range(p * p, 30000, p):
			prime[i] = 0
t = int(input())
while t != 0:
	d = int(input())
	p = prime.index(1, d + 1)
	q = prime.index(1, p + d)
	print(p * q)
	t -= 1


prime = [False, False] + [True] * 20010
for i in range(2, 142):
	if prime[i]:
		for j in range(i * i, 20012, i):
			prime[j] = False
all_prime = [i for i in range(2, 20012) if prime[i]]
num_prime = len(all_prime)
del prime
for _ in [0] * int(input()):
	d = int(input())
	index = -1
	left = 0
	right = num_prime - 1
	while left <= right:
		mid = left + (right - left) // 2
		if all_prime[mid] <= d:
			left = mid + 1
			continue
		if all_prime[mid] == d + 1:
			index = mid
			break
		if all_prime[mid] > d:
			if mid > 0 and all_prime[mid - 1] <= d:
				index = mid
				break
			right = mid - 1
			continue
	left = index + 1
	right = num_prime - 1
	first = all_prime[index]
	index = -1
	while left <= right:
		mid = left + (right - left) // 2
		if all_prime[mid] < first + d:
			left = mid + 1
			continue
		if all_prime[mid] == first + d:
			index = mid
			break
		if all_prime[mid] >= first + d:
			if mid > 0 and all_prime[mid - 1] < first + d:
				index = mid
				break
			right = mid - 1
			continue
	print(first * all_prime[index])


N = 3
N = 8 ** 5
a = [1] * N
i = 2
while i * i < N:
	a[i * i::i] = [0] * -(-N // i + i)
	i += 1
for s in [*open(0)][1:]:
	d = int(s)
	i = a.index(1, d + 1)
	print(i * a.index(1, i + d))


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve():
	MAXN = int(100000.0)
	primes = [True] * MAXN
	for i in range(2, MAXN):
		if i * i >= MAXN:
			break
		if primes[i]:
			for j in range(i * i, MAXN, i):
				primes[j] = False
	primes[0] = False
	primes[1] = False
	for i in range(mint()):
		d = mint()
		for x in range(1 + d, MAXN):
			if primes[x]:
				break
		for y in range(x + d, MAXN):
			if primes[y]:
				break
		print(x * y)
solve()


import sys
input = sys.stdin.readline

def iin():
	return int(input())

def sin():
	return input().strip()

def nin():
	return map(int, sin().split())

def lin():
	return list(map(int, sin().split()))

def p(x):
	print(x)

def pl(l):
	for i in l:
		print(i, end=' ')

def pnl(l):
	pl(l)
	print()

def pyn(x):
	if x:
		print('YES')
	else:
		print('NO')
l = [0] * 21001
for i in range(2, 21001):
	if l[i] == 0:
		l[i] = 1
		j = 2
		while i * j <= 21000:
			l[i * j] = 2
			j += 1
te = 1
te = iin()
while te > 0:
	d = iin()
	a = 1
	f = 0
	i = d + 1
	while f != 2:
		if l[i] == 1:
			a *= i
			f += 1
			i += d
			if f == 2:
				break
		else:
			i += 1
	print(a)
	te -= 1


from itertools import accumulate as ac
from collections import Counter as cc
from bisect import bisect_left as bsl
from bisect import bisect as bs
from math import factorial
from collections import OrderedDict as odict
from collections import defaultdict as dfd
import itertools
from statistics import mean
from math import ceil, sqrt, log, gcd
import math
import random
import time
from itertools import islice
from functools import lru_cache

def lcm(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def intinput():
	return int(input())

def strinputlist():
	return input().split()

def intinputiter():
	return map(int, input().split())

def intinputlist():
	return list(intinputiter())

def intinputset():
	return set(intinputiter())
abcstr = 'abcdefghijklmnopqrstuvwxyz'
mod = 998244353
inf = float('inf')

class whatIsPrime:
	odd = itertools.count(3, 2)
	below_1000 = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919]

	@classmethod
	def is_prime(self, n):
		if n % 6 not in (1, 5) and n not in (2, 3):
			return False
		for i in range(3, int(sqrt(n) + 1)):
			if n % i == 0:
				return False
		return n != 1

	@classmethod
	def euler(self, n):
		primes = []
		is_prime = [True] * (n + 1)
		for i in range(2, n + 1):
			if is_prime[i]:
				primes.append(i)
			for (j, p) in enumerate(primes):
				if p > n // i:
					break
				is_prime[i * p] = False
				if i % p == 0:
					break
		return primes

	@classmethod
	def pn(self, n):
		n = int(n)
		if n <= 1000:
			return self.below_1000[n - 1]
		s = n * math.log(n) * 1.2
		s = int(s)
		primes = self.euler(s)
		return primes[n - 1]

	@classmethod
	def count_prime(self, n):
		return len(self.euler(n))

	@classmethod
	def next_prime_or_this(self, n):
		if self.is_prime(n):
			return n
		while 1:
			n += 1
			if self.is_prime(n):
				return n

def sgcd(str1: str, str2: str):
	for i in range(min(len(str1), len(str2)), 0, -1):
		if len(str1) % i == 0 and len(str2) % i == 0:
			if str1[:i] * (len(str1) // i) == str1 and str1[:i] * (len(str2) // i) == str2:
				return str1[:i]
	return ''

def write(s):
	with open('test.txt', 'a+') as f:
		f.write(str(s) + '\n')
result = []

def backtrack(pairs: list, remain_list: list, pp: int):
	lena = len(remain_list)
	if not lena:
		result.append(pairs)
		return True
	for j in range(lena):
		for q in range(j + 1, lena):
			(a, b) = (remain_list[j], remain_list[q])
			if a + b != pp:
				continue
			pairs.append((a, b))
			remain_list.pop(j)
			remain_list.pop(q - 1)
			if backtrack(pairs[:], remain_list[:], max(a, b)):
				return True
			pairs.pop(-1)
			remain_list.append(a)
			remain_list.append(b)
t = intinput()
for i in range(t):
	d = intinput()
	k = [1]
	for j in range(2):
		k.append(whatIsPrime.next_prime_or_this(k[-1] + d))
	print(k[-1] * k[-2])


def isprime(p):
	if p <= 1:
		return False
	if p == 2:
		return True
	if p % 2 == 0:
		return False
	i = 3
	while i * i <= p:
		if p % i == 0:
			return False
		i += 2
	return True
for i in range(int(input())):
	d = int(input())
	p = d + 1
	while not isprime(p):
		p += 1
	q = p + d
	while not isprime(q):
		q += 1
	print(p * q)


import sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.buffer.readline())

def MI():
	return map(int, sys.stdin.buffer.readline().split())

def LI():
	return list(map(int, sys.stdin.buffer.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def BI():
	return sys.stdin.buffer.readline().rstrip()

def SI():
	return sys.stdin.buffer.readline().rstrip().decode()
inf = 10 ** 16
md = 10 ** 9 + 7

class Sieve:

	def __init__(self, n):
		self.plist = [2]
		min_prime_factor = [2, 0] * (n // 2 + 5)
		for x in range(3, n + 1, 2):
			if min_prime_factor[x] == 0:
				min_prime_factor[x] = x
				self.plist.append(x)
				if x ** 2 > n:
					continue
				for y in range(x ** 2, n + 5, 2 * x):
					if min_prime_factor[y] == 0:
						min_prime_factor[y] = x
		self.min_prime_factor = min_prime_factor

	def isprime(self, x):
		return self.min_prime_factor[x] == x

	def pfct(self, x):
		(pp, ee) = ([], [])
		while x > 1:
			mpf = self.min_prime_factor[x]
			if pp and mpf == pp[-1]:
				ee[-1] += 1
			else:
				pp.append(mpf)
				ee.append(1)
			x //= mpf
		return [(p, e) for (p, e) in zip(pp, ee)]
sv = Sieve(50000)
pp = sv.plist
from bisect import bisect_left as bl
for _ in range(II()):
	d = II()
	i = bl(pp, d + 1)
	a = pp[i]
	i = bl(pp, a + d)
	b = pp[i]
	print(a * b)


import sys
input = sys.stdin.readline

def debug():
	for i in range(10):
		pass

def mmm(a, b, m):
	res = 0
	a %= m
	while b:
		if b & 1:
			res = (res + a) % m
		a = 2 * a % m
		b >>= 1
	return res

def pw(a, b, c):
	ans = 1
	a = a % c
	if a == 0:
		return 0
	while b > 0:
		if b & 1:
			ans = ans * a % c
		b = b >> 1
		a = a * a % c
	return ans

def sieve(n, prime):
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
try:
	prime = [True] * 100005
	sieve(100001, prime)
	for _ in range(int(input())):
		n = int(input())
		req = 2
		ans = 1
		prev = 1
		for i in range(2, 100001):
			if prime[i] == True:
				diff = i - prev
				if diff >= n:
					ans *= i
					prev = i
					req -= 1
			if req == 0:
				break
		print(ans)
except EOFError as e:
	print(e)


is_prime = [True] * 30000
all_primes = set()
for i in range(len(is_prime)):
	if is_prime[i]:
		all_primes.add(i + 2)
		for j in range(i, len(is_prime), i + 2):
			is_prime[j] = False
t = int(input())
for _ in range(t):
	d = int(input())
	first_prime = 0
	second_prime = 0
	for i in range(d - 1, len(is_prime)):
		if i + 2 in all_primes:
			first_prime = i + 2
			break
	for i in range(first_prime + d - 2, len(is_prime)):
		if i + 2 in all_primes:
			second_prime = i + 2
			break
	print(first_prime * second_prime)


def isprime(n):
	for i in range(2, int(n ** 0.5 // 1) + 1):
		if n % i == 0:
			return 0
	return 1
t = int(input())
for i in range(t):
	d = int(input())
	a = d + 1
	while not isprime(a):
		a += 1
	b = a + d
	while not isprime(b):
		b = b + 1
	print(a * b)


import math

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	for i in range(5, int(math.sqrt(n) + 1), 6):
		if n % i == 0 or n % (i + 2) == 0:
			return False
	return True

def nxtPrime(N):
	if N <= 1:
		return 2
	prime = N
	found = False
	while not found:
		prime = prime + 1
		if isPrime(prime) == True:
			found = True
	return prime
for _ in range(int(input())):
	d = int(input())
	a1 = 1
	a2 = 1 + d
	if not isPrime(a2):
		a2 = nxtPrime(a2)
	a3 = a2 + d
	if not isPrime(a3):
		a3 = nxtPrime(a3)
	a4 = a2 * a3
	print(a4)


from math import sqrt

def zs(a):
	if a % 2 == 0 and a != 2:
		return True
	if a < 5000:
		for i in range(2, int((a + 1) / 2)):
			if a % i == 0:
				return True
	else:
		for i in range(2, 1000):
			if a % i == 0:
				return True
	return False
t = int(input())
a = []
for i in range(t):
	n = int(input())
	min = 1 + n
	while zs(min):
		min += 1
	max = min + n
	while zs(max):
		max += 1
	a.append(max * min)
for i in range(t):
	print(a[i])


def f(n):
	if n == 2:
		return True
	for i in range(2, int(n ** 0.5) + 2):
		if n % i == 0:
			return False
	return True
t = int(input())
for i in range(t):
	n = int(input())
	e1 = n + 1
	while not f(e1):
		e1 += 1
	e2 = e1 + n
	while not f(e2):
		e2 += 1
	print(e1 * e2)


import math

def SieveOfEratosthenes(n):
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = False
	prime[1] = False
prime = [True for i in range(100001)]
SieveOfEratosthenes(100000)
for j in range(int(input())):
	l = int(input())
	x = l + 1
	ans_ = 1
	for i in range(x, 100000):
		if prime[i]:
			ans_ *= i
			break
	for i in range(ans_ + l, 100000):
		if prime[i]:
			ans_ *= i
			break
	print(ans_)


def div(n):
	if n <= 1:
		return False
	for j in range(2, n):
		if n % j == 0:
			return False
	return True
t = int(input())
for j in range(0, t):
	d = int(input())
	st = 1 + d
	for j in range(st, 1000001):
		if div(j) == True:
			se = j
			break
	th = se + d
	for j in range(th, 1000001):
		if div(j) == True:
			th = j
			break
	print(str(se * th))


from bisect import bisect_right, bisect_left

def primes(n):
	is_prime = [True] * (n + 1)
	is_prime[0] = False
	is_prime[1] = False
	for i in range(2, int(n ** 0.5) + 1):
		if not is_prime[i]:
			continue
		for j in range(i * 2, n + 1, i):
			is_prime[j] = False
	return [i for i in range(n + 1) if is_prime[i]]
t = int(input())
p = primes(21000)
for _ in range(t):
	d = int(input())
	a = p[bisect_right(p, d)]
	b = p[bisect_right(p, a + d - 1)]
	print(a * b)


import math

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	for i in range(5, int(math.sqrt(n) + 1), 6):
		if n % i == 0 or n % (i + 2) == 0:
			return False
	return True

def nextPrime(N):
	if isPrime(N):
		return N
	prime = N
	found = False
	while not found:
		prime = prime + 1
		if isPrime(prime) == True:
			found = True
	return prime

def solve(d):
	first = nextPrime(d + 1)
	second = nextPrime(first + d)
	print(first * second)
t = int(input())
for t in range(t):
	d = int(input())
	solve(d)


t = int(input())
lst = [1] * 25001
n = len(lst) - 1
p = 2
while p * p <= n:
	if lst[p] == 1:
		for i in range(p * p, n + 1, p):
			lst[i] = 0
	p += 1
primelst = []
for i in range(2, n + 1):
	if lst[i] == 1:
		primelst.append(i)

def binS(lst, num):
	start = 0
	end = len(lst) - 1
	while start <= end:
		mid = (start + end) // 2
		if lst[mid] == num:
			return mid
		elif lst[mid] < num:
			start = mid + 1
		else:
			end = mid - 1
	if lst[mid] < num:
		mid += 1
	return mid
for _ in range(t):
	d = int(input())
	pind = binS(primelst, 1 + d)
	qind = binS(primelst, primelst[pind] + d)
	p = primelst[pind]
	q = primelst[qind]
	print(min(p ** 3, p * q))


def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	l = []
	for p in range(2, n + 1):
		if prime[p]:
			l.append(p)
	return l

def binarysearch(arr, a, b, element):
	ans = 0
	while a <= b:
		m = a + (b - a) // 2
		if arr[m] == element:
			return arr[m]
		elif arr[m] < element:
			a = m + 1
		else:
			b = m - 1
			ans = arr[m]
	return ans
first = SieveOfEratosthenes(100000)
for _ in range(int(input())):
	n = int(input())
	one = binarysearch(first, 0, len(first) + 1, n + 1)
	two = binarysearch(first, 0, len(first) + 1, one + n)
	print(one * two)


ll = lambda : map(int, input().split())
t = lambda : int(input())
ss = lambda : input()
from math import log10, log2, ceil, factorial as f, gcd
from collections import Counter

def f(n):
	i = 2
	while i * i <= n:
		if n % i == 0:
			return 0
		i += 1
	return 1
for _ in range(t()):
	n = t()
	x = n + 1
	while f(x) == 0:
		x += 1
	y = x + n
	while f(y) == 0:
		y += 1
	print(x * y)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
from math import *
from itertools import *
from collections import Counter
from bisect import *

def aa():
	return int(input())

def bb():
	return list(map(int, input().split()))

def cc():
	s = input()
	return s

def dd():
	return map(int, input().split())

def isprime(x):
	i = 2
	while i * i <= x:
		if x % i == 0:
			return 0
		i += 1
	return 1

def solve():
	d = aa()
	n = d + 1
	while not isprime(n):
		n += 1
	b = d + n
	while not isprime(b):
		b += 1
	print(min(n ** 3, n * b))
t = aa()
while t:
	solve()
	t -= 1


t = int(input())
p = [True for i in range(20012)]
p1 = 2
while p1 * p1 <= 20012:
	if p[p1] == True:
		for j in range(p1 * 2, 20012, p1):
			p[j] = False
	p1 += 1
	p[0] = False
for i in range(0, t):
	m = int(input())
	x = 1 + m
	while x <= 20012:
		if p[x] == True:
			break
		x += 1
	y = x + m
	while y <= 20012:
		if p[y] == True:
			break
		y += 1
	ans = x * y
	print(int(ans))


from math import gcd
t = int(input())

def is_prime(x):
	return all((x % i for i in range(2, int(x ** 0.5) + 1)))

def next_prime(x):
	for a in range(x + 1, 2 * x):
		if is_prime(a):
			return a
for tc in range(t):
	n = int(input())
	a = n + 1 if is_prime(n + 1) else next_prime(n)
	b = a + n if is_prime(a + n) else next_prime(a + n)
	ans = a * b / gcd(a, b)
	print(int(ans))


def isPrime(num):
	r = num ** 0.5
	r = int(r)
	for i in range(2, r + 1):
		if num % i == 0:
			return False
	return True
for c in range(int(input())):
	dis = int(input())
	a = 1 + dis
	while not isPrime(a):
		a += 1
	b = a + dis
	while not isPrime(b):
		b += 1
	print(a * b)


from bisect import bisect_left as bsl
t = int(input())
candidates = [2 * i + 1 for i in range(1, 10006)]
primelist = [2]
p = 3
while p ** 2 <= 20011:
	primelist.append(p)
	candidates = [c for c in candidates if c % p]
	p = candidates[0]
primelist += candidates
memo = [0] * 10000
for _ in range(t):
	d = int(input())
	if memo[d - 1]:
		print(memo[d - 1])
	else:
		b1 = bsl(primelist, 1 + d)
		p1 = primelist[b1]
		b2 = bsl(primelist, p1 + d)
		p2 = primelist[b2]
		print(p1 * p2)
		memo[d - 1] = p1 * p2


import math

def prime(n):
	temm = [2, 3, 5, 7, 11]
	if n in temm:
		return n
	else:
		max_div = math.floor(math.sqrt(n))
		for i in range(2, 1 + max_div):
			if n % i == 0:
				return 0
		return n
t = int(input())
a = [1]
temp = 0
for i in range(t):
	d = int(input())
	n = 1 + d
	while len(a) < 3:
		temp = prime(n)
		if temp != 0:
			a.append(temp)
			n = n + d
			continue
		n = n + 1
	a.append(a[1] * a[2])
	print(a[3])
	a.clear()
	a.append(1)


import bisect

def s(n):
	global d
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	l = 0
	pri = []
	for p in range(2, n + 1):
		if prime[p]:
			pri.append(p)
			d[p] = True
		else:
			d[p] = False
	return pri

def gcd(a, b):
	if a % b == 0:
		return b
	return gcd(b, a % b)
d = {}
arr = s(100000)
for i in range(int(input())):
	n = int(input())
	p = 1 + n
	if d[p] == True:
		an1 = p
	else:
		an1 = arr[bisect.bisect_left(arr, 1 + n)]
	q = an1 + n
	if d[q] == True:
		an2 = q
	else:
		an2 = arr[bisect.bisect_left(arr, q)]
	an = an1 * an2 // gcd(an2, an1)
	print(an)


from sys import stdin

def sieve(size):
	sie = [-1] * size
	for i in range(2, int(size ** 0.5) + 1):
		if sie[i] != -1:
			continue
		for j in range(i * i, size, i):
			if sie[j] == -1:
				sie[j] = i
	return sie
s = sieve(50000)
for _ in range(int(stdin.readline())):
	d = int(stdin.readline())
	min_div = d + 1
	while s[min_div] != -1:
		min_div += 1
	sec_div = min_div + d
	while s[sec_div] != -1:
		sec_div += 1
	print(min_div * sec_div)


(n, p) = (21000, 2)
prime = [True for i in range(n + 1)]
(prime[0], prime[1]) = (False, False)
while p * p <= n:
	if prime[p] == True:
		for i in range(p * p, n + 1, p):
			prime[i] = False
	p += 1
for _ in range(int(input())):
	d = int(input())
	(a, b) = (0, 0)
	for i in range(d + 1, n):
		if prime[i]:
			a = i
			break
	for i in range(a + d, n):
		if prime[i]:
			b = i
			break
	print(a * b)


import bisect
from collections import defaultdict
import math

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	for i in range(5, int(math.sqrt(n) + 1), 6):
		if n % i == 0 or n % (i + 2) == 0:
			return False
	return True

def nextPrime(N):
	if N <= 1:
		return 2
	prime = N - 1
	found = False
	while not found:
		prime = prime + 1
		if isPrime(prime) == True:
			found = True
	return prime

def solve(d):
	x1 = nextPrime(1 + d)
	x2 = nextPrime(x1 + d)
	return x1 * x2
t = int(input(''))
ans = []
while t > 0:
	n = int(input(''))
	ans.append(solve(n))
	t -= 1
for i in ans:
	print(i)


def isprime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True
for _ in range(int(input())):
	n = int(input())
	b = 1 + n
	while not isprime(b):
		b += 1
	c = b + n
	while not isprime(c):
		c += 1
	print(b * c)


def sqrt(s):
	return int(s ** 0.5)

def isPrime(n):
	if n <= 1:
		return False
	for i in range(2, sqrt(n) + 1):
		if n % i == 0:
			return False
	return True

def solve(n):
	a = 1
	for i in range(a + n, 100000000):
		if isPrime(i):
			a *= i
			break
	for i in range(a + n, 100000000):
		if isPrime(i):
			a *= i
			break
	return a
for _ in range(int(input())):
	print(solve(int(input())))


def is_prime(x):
	end = int(x ** 0.5)
	for i in range(3, end + 2, 2):
		if x % i == 0:
			return False
	return True

def main():
	t = int(input())
	for _ in range(t):
		d = int(input())
		if d == 1:
			print(6)
			continue
		if d % 2:
			d += 1
		first = d + 1
		while not is_prime(first):
			first += 2
		second = first + d
		while not is_prime(second):
			second += 2
		print(first * second)
main()


import math
t = int(input())
for i in range(t):
	d = int(input())
	if d == 1:
		print(6)
	else:
		l = []
		c = 0
		t1 = d + 1
		while c != 2:
			if t1 % 2 == 0:
				t1 += 1
			else:
				j = 2
				f = 0
				while j <= int(math.sqrt(t1)):
					if t1 % j == 0:
						f = 1
						break
					else:
						j += 1
				if f == 0:
					c += 1
					l.append(t1)
					t1 += d
				else:
					t1 += 1
		print(l[0] * l[1])


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()
import math
import time

def is_prime(n):
	if n <= 1:
		return False
	max_div = math.floor(math.sqrt(n))
	for i in range(2, 1 + max_div):
		if n % i == 0:
			return False
	return True
a = []
d = {}
c = 0
for n in range(1, 100000):
	x = is_prime(n)
	if x:
		a.append(n)
		if d.get(n) == None:
			d[n] = 1
for _ in range(int(input())):
	n = int(input())
	b = []
	b.append(1)
	ans = 1 + n
	if d.get(ans) != None:
		m = ans
		b.append(ans)
		p = a.index(ans)
	else:
		for i in range(len(a)):
			if a[i] >= ans:
				b.append(a[i])
				p = i
				m = a[i]
				break
	ans = b[-1] + n
	if d.get(ans) != None:
		n = ans
		p = a.index(ans)
		b.append(ans)
	else:
		for i in range(p + 1, len(a)):
			if a[i] >= ans:
				b.append(a[i])
				n = a[i]
				break
	print(m * n)


from sys import stdin
input = lambda : stdin.readline().strip()
lin = lambda : list(map(int, input().split()))
iin = lambda : int(input())
main = lambda : map(int, input().split())
from math import ceil, sqrt, factorial, log
from collections import deque
from bisect import bisect_left

def gcd(a, b):
	(a, b) = (max(a, b), min(a, b))
	while a % b != 0:
		(a, b) = (b, a % b)
	return b
mod = 998244353
prime = [True for i in range(pow(10, 5) + 4)]
d = []

def SieveOfEratosthenes(n):
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for i in range(2, n + 1):
		if prime[i] == True:
			d.append(i)
SieveOfEratosthenes(pow(10, 5))

def solve(we):
	n = iin()
	a = 1 + n
	t = bisect_left(d, a)
	while d[t] < a:
		t += 1
	a = d[t]
	b = a + n
	t = bisect_left(d, b)
	while d[t] < b:
		t += 1
	b = d[t]
	print(a * b)
qwe = 1
qwe = int(input())
for _ in range(qwe):
	solve(_ + 1)


def isPr(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True
for _ in range(int(input())):
	d = int(input())
	c = d
	d += 1
	while not isPr(d):
		d += 1
	a = c + d
	while not isPr(a):
		a += 1
	print(a * d)


from math import sqrt
x = [0, 0] + [i for i in range(2, 21000)]
for i in range(4, 21000, 2):
	x[i] = 0
for i in range(3, int(sqrt(21000)), 2):
	if x[i]:
		for j in range(i + i, 21000, i):
			x[j] = 0
x = list(filter(lambda y: y != 0, x))

def s(d):
	(a, b) = (0, 0)
	for i in x:
		if i >= d + 1:
			a = i
			break
	for i in x:
		if i >= a + d:
			b = i
			break
	print(a * b)
for _ in range(int(input())):
	d = int(input())
	s(d)


from bisect import bisect_left
from sys import stdin, gettrace, stderr
if gettrace():

	def inputi():
		return input()
else:

	def input():
		return next(stdin)[:-1]

	def inputi():
		return stdin.buffer.readline()
PRIMES = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001, 16007, 16033, 16057, 16061, 16063, 16067, 16069, 16073, 16087, 16091, 16097, 16103, 16111, 16127, 16139, 16141, 16183, 16187, 16189, 16193, 16217, 16223, 16229, 16231, 16249, 16253, 16267, 16273, 16301, 16319, 16333, 16339, 16349, 16361, 16363, 16369, 16381, 16411, 16417, 16421, 16427, 16433, 16447, 16451, 16453, 16477, 16481, 16487, 16493, 16519, 16529, 16547, 16553, 16561, 16567, 16573, 16603, 16607, 16619, 16631, 16633, 16649, 16651, 16657, 16661, 16673, 16691, 16693, 16699, 16703, 16729, 16741, 16747, 16759, 16763, 16787, 16811, 16823, 16829, 16831, 16843, 16871, 16879, 16883, 16889, 16901, 16903, 16921, 16927, 16931, 16937, 16943, 16963, 16979, 16981, 16987, 16993, 17011, 17021, 17027, 17029, 17033, 17041, 17047, 17053, 17077, 17093, 17099, 17107, 17117, 17123, 17137, 17159, 17167, 17183, 17189, 17191, 17203, 17207, 17209, 17231, 17239, 17257, 17291, 17293, 17299, 17317, 17321, 17327, 17333, 17341, 17351, 17359, 17377, 17383, 17387, 17389, 17393, 17401, 17417, 17419, 17431, 17443, 17449, 17467, 17471, 17477, 17483, 17489, 17491, 17497, 17509, 17519, 17539, 17551, 17569, 17573, 17579, 17581, 17597, 17599, 17609, 17623, 17627, 17657, 17659, 17669, 17681, 17683, 17707, 17713, 17729, 17737, 17747, 17749, 17761, 17783, 17789, 17791, 17807, 17827, 17837, 17839, 17851, 17863, 17881, 17891, 17903, 17909, 17911, 17921, 17923, 17929, 17939, 17957, 17959, 17971, 17977, 17981, 17987, 17989, 18013, 18041, 18043, 18047, 18049, 18059, 18061, 18077, 18089, 18097, 18119, 18121, 18127, 18131, 18133, 18143, 18149, 18169, 18181, 18191, 18199, 18211, 18217, 18223, 18229, 18233, 18251, 18253, 18257, 18269, 18287, 18289, 18301, 18307, 18311, 18313, 18329, 18341, 18353, 18367, 18371, 18379, 18397, 18401, 18413, 18427, 18433, 18439, 18443, 18451, 18457, 18461, 18481, 18493, 18503, 18517, 18521, 18523, 18539, 18541, 18553, 18583, 18587, 18593, 18617, 18637, 18661, 18671, 18679, 18691, 18701, 18713, 18719, 18731, 18743, 18749, 18757, 18773, 18787, 18793, 18797, 18803, 18839, 18859, 18869, 18899, 18911, 18913, 18917, 18919, 18947, 18959, 18973, 18979, 19001, 19009, 19013, 19031, 19037, 19051, 19069, 19073, 19079, 19081, 19087, 19121, 19139, 19141, 19157, 19163, 19181, 19183, 19207, 19211, 19213, 19219, 19231, 19237, 19249, 19259, 19267, 19273, 19289, 19301, 19309, 19319, 19333, 19373, 19379, 19381, 19387, 19391, 19403, 19417, 19421, 19423, 19427, 19429, 19433, 19441, 19447, 19457, 19463, 19469, 19471, 19477, 19483, 19489, 19501, 19507, 19531, 19541, 19543, 19553, 19559, 19571, 19577, 19583, 19597, 19603, 19609, 19661, 19681, 19687, 19697, 19699, 19709, 19717, 19727, 19739, 19751, 19753, 19759, 19763, 19777, 19793, 19801, 19813, 19819, 19841, 19843, 19853, 19861, 19867, 19889, 19891, 19913, 19919, 19927, 19937, 19949, 19961, 19963, 19973, 19979, 19991, 19993, 19997, 20011, 20021, 20023, 20029, 20047, 20051, 20063, 20071, 20089, 20101, 20107, 20113, 20117, 20123, 20129, 20143, 20147, 20149, 20161, 20173, 20177, 20183, 20201, 20219, 20231, 20233, 20249, 20261, 20269, 20287, 20297, 20323, 20327, 20333, 20341, 20347, 20353, 20357, 20359, 20369, 20389, 20393, 20399, 20407, 20411]

def solve():
	d = int(input())
	p1 = PRIMES[bisect_left(PRIMES, d + 1)]
	p2 = PRIMES[bisect_left(PRIMES, p1 + d)]
	print(p1 * p2)

def main():
	t = int(input())
	for _ in range(t):
		solve()
main()


arr = [True for i in range(100000)]
arr[0] = False
arr[1] = False
arr[2] = True
for i in range(2, 100000):
	if arr[i]:
		for j in range(i * i, 100000, i):
			arr[j] = False

def solve():
	d = int(input())
	val1 = 0
	val2 = 0
	for i in range(1 + d, 100000):
		if arr[i]:
			val1 = i
			break
	for i in range(val1 + d, 100000):
		if arr[i]:
			val2 = i
			break
	print(val1 * val2)
for i in range(int(input())):
	solve()


def main():
	n = 30000
	is_prime = [1] * n
	for i in range(2, n):
		if is_prime[i]:
			for j in range(i * i, n, i):
				is_prime[j] = 0
	for _ in range(int(input())):
		d = int(input())
		p = is_prime.index(1, d + 1)
		q = is_prime.index(1, p + d)
		print(p * q)
main()


from functools import reduce

def isprime(a):
	n = a ** (1 / 2)
	count = 1
	for i in range(2, int(n) + 1):
		if a % i != 0:
			count = count + 1
		else:
			break
	if count == int(n):
		return 1
	else:
		return 0
t = int(input())
for i in range(t):
	a = 1
	b = 0
	li = []
	d = int(input())
	a = a + d
	while b != 2:
		if isprime(a):
			b = b + 1
			li.append(a)
			a = a + d
		else:
			a = a + 1
	print(reduce(lambda x, y: x * y, li))


import sys
MOD = 1000000007
import math

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_int():
	return int(sys.stdin.readline())

def get_line():
	return sys.stdin.readline().strip()

def write_line(out):
	return sys.stdout.write(str(out) + '\n')
primes = [True] * (3 * 10 ** 4)
primes[0] = False
primes[1] = False
i = 2
prime_numbers = []
while i * i <= len(primes):
	if primes[i]:
		for j in range(i + i, len(primes), i):
			primes[j] = False
	i += 1
for (i, val) in enumerate(primes):
	if val:
		prime_numbers.append(i)

def bin_search(key):
	l = 0
	r = len(prime_numbers)
	while l < r:
		mid = (l + r) // 2
		if prime_numbers[mid] >= key:
			r = mid
		else:
			l = mid + 1
	return prime_numbers[l]

def solve():
	n = int(input())
	first = bin_search(1 + n)
	second = bin_search(first + n)
	return first * second
t = get_int()
while t:
	write_line(solve())
	t -= 1


def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def main():
	T = int(input())
	for c in range(T):
		d = int(input())
		p = d + 1
		while not isPrime(p):
			p += 1
		q = p + d
		while not isPrime(q) and q < p * p:
			q += 1
		print(p * q)
main()


t = int(input())
while t:
	d = int(input())
	if d == 1:
		print(6)
	else:
		a = d + 1
		while 1:
			if a % 2 == 0:
				a += 1
			else:
				c = 0
				for i in range(2, a):
					if a % i == 0:
						c = 1
						break
				if c == 0:
					break
				a += 1
		b = d + a
		while 1:
			if b % 2 == 0:
				b += 1
			else:
				c = 0
				for i in range(2, b):
					if b % i == 0:
						c = 1
						break
				if c == 0:
					break
				b += 1
		print(a * b)
	t -= 1


import math

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	for i in range(5, int(math.sqrt(n) + 1), 6):
		if n % i == 0 or n % (i + 2) == 0:
			return False
	return True

def nextPrime(N):
	if N <= 1:
		return 2
	prime = N
	found = False
	while not found:
		prime = prime + 1
		if isPrime(prime) == True:
			found = True
	return prime
for _ in range(int(input())):
	n = int(input())
	shan = [1]
	k = n
	shan.append(nextPrime(k))
	k = shan[-1] + n - 1
	shan.append(nextPrime(k))
	siri = 1
	for a in shan:
		siri *= a
	print(siri)


def is_prime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
for _ in range(int(input())):
	n = int(input())
	a = 1
	b = a + n
	while not is_prime(b):
		b = b + 1
	c = b + n
	while not is_prime(c):
		c += 1
	print(b * c)


import math

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def isprime(n):
	for q in range(2, int(math.sqrt(n)) + 1):
		if n % q == 0:
			return False
	return True
for _ in range(int(input())):
	n = int(input())
	ans = 1
	num = 1 + n
	while True:
		if isprime(num):
			break
		num += 1
	ans *= num
	num += n
	while True:
		if isprime(num):
			break
		num += 1
	ans *= num
	print(ans)


from bisect import bisect_left as bl
max_n = 3 * 10 ** 4
(isComposite, primes) = ([1] * 2 + [0] * (max_n - 2), [])
for i in range(2, max_n):
	if isComposite[i] == 0:
		primes.append(i)
		for j in range(2 * i, max_n, i):
			isComposite[j] += 1
for _ in range(int(input())):
	d = int(input())
	p1 = primes[bl(primes, d + 1)]
	p2 = primes[bl(primes, d + p1)]
	print(p1 * p2)


def prime(n):
	dicti = {}
	dicti[0] = False
	dicti[1] = False
	for i in range(2, n):
		if i not in dicti:
			dicti[i] = True
			for j in range(i * 2, n + 1, i):
				dicti[j] = False
	return dicti
dicti = prime(20014)
for _ in range(int(input())):
	d = int(input())
	ans = 1
	i = d + 1
	if d == 1:
		print('6')
	else:
		k = 0
		for j in range(i, len(dicti)):
			if dicti[j] == True:
				k = j
				break
		ans *= k
		i = ans + d
		for j in range(i, len(dicti)):
			if dicti[j] == True:
				k = j
				break
		ans *= k
		print(ans)


import sys, os, time, json, random, math
n = 10000 * 5
a = list(range(n + 1))
a[1] = 0
lst = []
i = 2
while i <= n:
	if a[i] != 0:
		lst.append(a[i])
		for j in range(i, n + 1, i):
			a[j] = 0
	i += 1
next_simp = {}
c = 0
for i in range(n):
	if i > lst[c]:
		c += 1
	if c >= len(lst):
		break
	next_simp[i] = lst[c]
tt = int(input())
res = []
for t in range(tt):
	d = int(input())
	s1 = next_simp[1 + d]
	s2 = next_simp[s1 + d]
	res.append(s1 * s2)
for r in res:
	print(r)


def seive():
	max_num = 10 ** 6
	prime_lst = [True] * max_num
	prime_lst[0] = False
	prime_lst[1] = False
	for i in range(1, max_num):
		if prime_lst[i]:
			curr = 2 * i
			for j in range(curr, max_num, i):
				prime_lst[j] = False
	return prime_lst

def func():
	a = 1
	b = a + num
	while True:
		if prime_lst[b]:
			break
		b += 1
	c = b + num
	while True:
		if prime_lst[c]:
			break
		c += 1
	print(c * b)
prime_lst = seive()
for _ in range(int(input())):
	num = int(input())
	func()


def sieve(n):
	sieve = [True] * n
	i = 2
	while i * i < n:
		sieve[i * i::i] = [False] * -(-n // i + i)
		i += 1
	return [i for i in range(2, n) if sieve[i]]
L = sieve(8 ** 5)
for i in range(int(input())):
	from bisect import bisect_left
	n = int(input())
	i = bisect_left(L, n + 1)
	j = bisect_left(L, n + L[i])
	print(L[i] * L[j])


from math import floor, sqrt

def sieve_of_eratosthenes(n):
	prime_numbers = [True] * n
	for i in range(2, floor(sqrt(n)) + 1):
		if prime_numbers[i]:
			for j in range(i * i, n, i):
				prime_numbers[j] = False
	return prime_numbers
primes_flags = sieve_of_eratosthenes(50000)
for t in range(int(input())):
	d = int(input())
	prime_divisors = [1]
	i = 1 + d
	while i < len(primes_flags):
		if primes_flags[i]:
			prime_divisors.append(i)
			i += d - 1
			if len(prime_divisors) >= 3:
				print(prime_divisors[1] * prime_divisors[2])
				break
		i += 1


from collections import deque, defaultdict, Counter
import math
from sys import stdin, stdout
import sys

def inp():
	return int(stdin.readline())

def inlt():
	return list(map(int, stdin.readline().split()))

def insr():
	return list(stdin.readline().strip())

def invr():
	return map(int, stdin.readline().split())
from queue import Queue
q = Queue()
import itertools
global vis, dis, graph

def bfs(source_node, vis, graph, dis):
	q.put(source_node)
	vis[source_node] = True
	dis[source_node] = 0
	while not q.empty():
		current_node = q.get()
		for neighbour in graph[current_node]:
			if vis[neighbour] == False:
				q.put(neighbour)
				dis[neighbour] = dis[current_node] + 1
				vis[neighbour] = True
import math

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def is_prime(n):
	if n == 1:
		return False
	i = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	for i in range(5, int(math.sqrt(n) + 1), 6):
		if n % i == 0 or n % (i + 2) == 0:
			return False
	return True

def nextPrime(N):
	if N <= 1:
		return 2
	prime = N
	found = False
	while not found:
		prime = prime + 1
		if isPrime(prime) == True:
			found = True
	return prime

def main():
	for __ in range(inp()):
		d = inp()
		ans = d + 1
		f = 0
		z = 0
		i = ans
		while True:
			if is_prime(i):
				f = i
				break
			i += 1
		i += d
		while True:
			if is_prime(i):
				z = i
				break
			i += 1
		print(f * z)
main()


def doit():
	d = int(input())
	for i in range(d + 1, 30001):
		if a[i]:
			if i * i - i >= d and i * i * i - i * i >= d:
				ans = i * i * i
				break
	for i in range(d + 1, 30001):
		if a[i]:
			p1 = i
			break
	for i in range(p1 + d, 30001):
		if a[i]:
			p2 = i
			break
	ans = min(ans, p1 * p2)
	print(ans)
a = [True] * 30010
a[0] = False
a[1] = False
for i in range(2, 30001):
	if a[i]:
		for j in range(i * 2, 30001, i):
			a[j] = False
T = int(input())
for _ in range(T):
	doit()


import math

def input_int():
	return int(input())

def input_list():
	return input().split(' ')

def input_list_int():
	return list(map(int, input_list()))

def z_func(s):
	n = len(s)
	z = [0] * n
	l = r = 0
	for i in range(1, n):
		if r >= i:
			z[i] = min(z[i - l], r - i + 1)
		while z[i] + i < n and s[z[i]] == s[z[i] + i]:
			z[i] += 1
		if i + z[i] - 1 > r:
			l = i
			r = i + z[i] - 1
	return z

def isPrime(n):
	idx = 2
	while idx * idx <= n:
		if n % idx == 0:
			return 0
		idx += 1
	return 1

def solve():
	d = input_int()
	a = d + 1
	while not isPrime(a):
		a += 1
	b = a + d
	while not isPrime(b):
		b += 1
	print(b * a)
query_count = 1
query_count = input_int()
while query_count:
	query_count -= 1
	solve()


import math

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	for i in range(5, int(math.sqrt(n) + 1), 6):
		if n % i == 0 or n % (i + 2) == 0:
			return False
	return True

def nextPrime(N):
	if N <= 1:
		return 2
	prime = N
	found = False
	while not found:
		prime = prime + 1
		if isPrime(prime) == True:
			found = True
	return prime
for i in range(int(input())):
	n = int(input())
	if isPrime(n + 1):
		l = n * 2 + 1
		if isPrime(l):
			print((n + 1) * l)
		else:
			print((n + 1) * nextPrime(l))
	else:
		a = nextPrime(n)
		l = a + n
		if isPrime(l):
			print(a * l)
		else:
			print(a * nextPrime(l))


MAXD = 30001
sieve = [True] * MAXD
for i in range(2, MAXD):
	if sieve[i]:
		for j in range(i << 1, MAXD, i):
			sieve[j] = False
for _ in range(int(input())):
	d = int(input())
	if d == 1:
		print(6)
	else:
		a = d + 1
		while not sieve[a]:
			a += 1
		b = d + a
		while not sieve[b]:
			b += 1
		print(a * b)


def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
for _ in range(int(input())):
	d = int(input())
	a = 1 + d
	while 1:
		if isPrime(a):
			break
		a += 1
	b = a + d
	while 1:
		if isPrime(b):
			break
		b += 1
	print(a * b)


from math import sqrt
n = int(input())

def prime_up_to(n):
	L = [True] * (n + 1)
	for i in range(2, round(sqrt(n)) + 1):
		if L[i]:
			e = i * i
			while e <= n:
				L[e] = False
				e += i
	return [i for i in range(2, n + 1) if L[i]]
a = prime_up_to(20050)
for i in range(n):
	k = int(input())
	(l, r) = (0, len(a) - 1)
	while l < r:
		mid = (l + r) // 2
		if a[mid] >= k + 1:
			r = mid
		else:
			l = mid + 1
	b = a[r]
	(l, r) = (0, len(a) - 1)
	while l < r:
		mid = (l + r) // 2
		if a[mid] >= k + b:
			r = mid
		else:
			l = mid + 1
	c = a[r]
	print(b * c)


t = int(input())
prime = [True] * 40000
prime[0] = False
prime[1] = False
for i in range(2, 40000):
	if prime[i]:
		for j in range(i + i, 40000, i):
			prime[j] = False
for i in range(t):
	d = int(input())
	factor = [1]
	j = 1 + d
	while True:
		if len(factor) == 3:
			break
		if prime[j]:
			if len(factor) == 2:
				if factor[0] * factor[1] * j - j < d:
					continue
			factor.append(j)
			j += d
			continue
		j += 1
	print(factor[0] * factor[1] * factor[2])


import math

def getint():
	return [int(i) for i in input().split()]

def getstr():
	return [str(i) for i in input().split()]
prime = [1] * 30000
for p in range(2, 30000):
	if prime[p] == 1:
		for i in range(p * p, 30000, p):
			prime[i] = 0

def solve():
	d = int(input())
	p = prime.index(1, d + 1)
	q = prime.index(1, p + d)
	print(p * q)
for _ in range(int(input())):
	solve()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):

	def __init__(self, file):
		self.newlines = 0
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline()

def RL():
	return map(int, sys.stdin.readline().split())

def RLL():
	return list(map(int, sys.stdin.readline().split()))

def N():
	return int(input())

def S():
	return input().strip()

def print_list(l):
	print(''.join(map(str, l)))

def judgePrime(n):
	if n < 3:
		return []
	output = [1] * n
	(output[0], output[1]) = (0, 0)
	for i in range(2, int(n ** 0.5) + 1):
		if output[i]:
			output[i * i:n:i] = [0] * ((n - 1 - i * i) // i + 1)
	return output
primes = judgePrime(30000)
for _ in range(N()):
	d = N()
	a = d + 1
	while primes[a] == 0:
		a += 1
	b = a + d
	while primes[b] == 0:
		b += 1
	print(a * b)


M = 20020
is_prime = [False, False] + [True for i in range(2, M)]
for d in range(2, M):
	for k in range(2 * d, M, d):
		is_prime[k] = False
ntests = int(input())
for t in range(ntests):
	d = int(input())
	p = d + 1
	while not is_prime[p]:
		p += 1
	q = p + d
	while not is_prime[q]:
		q += 1
	print(p * q)


from bisect import bisect_left

def ints():
	return list(map(int, input().split()))

def primes(n):
	ret = [2, 3]
	for p in range(5, n, 2):
		is_prime = True
		for q in ret:
			if q * q > p:
				break
			if p % q == 0:
				is_prime = False
				break
		if is_prime:
			ret.append(p)
	return ret
P = primes(30000)

def go():
	(d,) = ints()
	ans = solve(d)
	print(ans)

def solve(d):
	pi = bisect_left(P, 1 + d)
	p = P[pi]
	qi = bisect_left(P, p + d)
	q = P[qi]
	return p * q
(num_cases,) = ints()
for case_num in range(num_cases):
	go()


import math
N = 20011
M = int(math.sqrt(N))
sieve = [True for _ in range(N + 1)]
sieve[0] = False
sieve[1] = False
for p in range(2, M + 1):
	if sieve[p]:
		for j in range(p * p, N + 1, p):
			sieve[j] = False
t = int(input())
for _ in range(t):
	d = int(input())
	p1 = sieve.index(1, 1 + d)
	p2 = sieve.index(1, p1 + d)
	print(p1 * p2)


from math import sqrt, floor

def check(n):
	for i in range(2, floor(sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True
t = int(input())
for _ in range(t):
	d = int(input())
	j = d + 1
	while check(j) == False:
		j = j + 1
	jj = j + d
	while check(jj) == False:
		jj = jj + 1
	ans1 = j ** 3
	ans2 = j * jj
	print(min(ans1, ans2))


from sys import stdin
dct = {i: 1 for i in range(2, 30001)}
for i in range(2, 190):
	if i not in dct:
		continue
	else:
		for j in range(2, 30000 // i + 1):
			if i * j in dct:
				del dct[i * j]
lst = sorted(dct.keys())
length = len(lst)
t = int(stdin.readline())
for _ in range(t):
	d = int(stdin.readline())
	jump = length - 1
	position1 = 0
	while jump > 0:
		if lst[position1 + jump] > d + 1:
			jump //= 2
		else:
			position1 += jump
	if lst[position1] >= d + 1:
		so1 = lst[position1]
	else:
		so1 = lst[position1 + 1]
	position2 = int(position1)
	jump = length
	while jump > 0:
		if position2 + jump >= length or lst[position2 + jump] > d + so1:
			jump //= 2
		else:
			position2 += jump
	if lst[position2] >= d + so1:
		so2 = lst[position2]
	else:
		so2 = lst[position2 + 1]
	print(so1 * so2)


N = 2 ** 15
is_prime = [1] * N
i = 2
while i * i < N:
	is_prime[i * i:N:i] = [0] * -(-N // i + i)
	i += 1
for _ in range(int(input())):
	d = int(input())
	i = is_prime.index(1, d + 1)
	j = is_prime.index(1, i + d)
	print(i * j)


import math

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	for i in range(5, int(math.sqrt(n) + 1), 6):
		if n % i == 0 or n % (i + 2) == 0:
			return False
	return True

def nextPrime(N):
	if N <= 1:
		return 2
	prime = N
	found = False
	while not found:
		prime = prime + 1
		if isPrime(prime) == True:
			found = True
	return prime

def check(num):
	if num > 1:
		for i in range(2, num):
			if num % i == 0:
				break
		else:
			return 1
	else:
		return 0
try:
	for i in range(int(input())):
		d = int(input())
		a = 1
		if check(a + d):
			b = a + d
		else:
			b = nextPrime(a + d)
		if check(b + d):
			c = b + d
		else:
			c = nextPrime(b + d)
		ans = b * c
		if d == 1:
			print(6)
		elif d == 2:
			print(15)
		else:
			print(ans)
except:
	pass


def isprime(n):
	while isPrime[n] == False:
		n += 1
	return n

def prime(n):
	i = 2
	while i < n:
		if isPrime[i] == True:
			j = 2
			while i * j < n:
				isPrime[i * j] = False
				j += 1
		i += 1
t = int(input())
isPrime = []
for i in range(30000):
	isPrime.append(True)
prime(30000)
while t:
	t -= 1
	d = int(input())
	ans = isprime(d + 1)
	ans *= isprime(ans + d)
	print(ans)


import math
import string
import random
import sys
from random import randrange
from collections import deque
from collections import defaultdict
from bisect import bisect, bisect_right, bisect_left

def data():
	return sys.stdin.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
n = 200000
prime = [True for i in range(n + 1)]
p = 2
while p * p <= n:
	if prime[p] == True:
		for i in range(p * 2, n + 1, p):
			prime[i] = False
	p += 1
prime[0] = False
prime[1] = False
for _ in range(int(input())):
	d = int(data())
	a = [1]
	k = d + 1
	while not prime[k]:
		k += 1
	a.append(k)
	k += d
	while not prime[k]:
		k += 1
	a.append(k)
	ans = 1
	for i in a:
		ans *= i
	print(ans)


import bisect
mex = 30000
vis = [False for i in range(mex)]
prime = []

def sieve():
	vis = [True for i in range(mex)]
	vis[0] = vis[1] = False
	for i in range(2, mex):
		if vis[i]:
			prime.append(i)
		j = 0
		while j < len(prime) and i * prime[j] < mex:
			vis[i * prime[j]] = False
			if i % prime[j] == 0:
				break
			j += 1
sieve()
for _ in range(int(input())):
	n = int(input())
	num = -1
	i = 0
	while i < len(prime) and num == -1:
		if prime[i] - 1 >= n:
			num = prime[i]
		i += 1
	lo = 0
	hi = len(prime) - 1
	while lo < hi:
		mid = (lo + hi) // 2
		if prime[mid] >= num + n:
			hi = mid
		else:
			lo = mid
		if hi - lo == 1:
			break
	if prime[lo] >= num + n:
		ano = prime[lo]
	else:
		ano = prime[hi]
	print(num * ano)


import bisect
primes = []

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	c = 0
	for p in range(2, n):
		if prime[p]:
			primes.append(p)
			c += 1
	return c
c = SieveOfEratosthenes(50000)
for _ in range(int(input())):
	d = int(input())
	sum = 1
	ind = 0
	t2 = 1
	i1 = bisect.bisect_left(primes, d + 1)
	sum = primes[i1]
	i2 = bisect.bisect_left(primes, sum + d)
	t2 = primes[i2]
	print(sum * t2)


def fun(n):
	if n == 1:
		return False
	if n == 2 or n == 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	for i in range(5, int(n ** 0.5) + 1, 6):
		if n % i == 0 or n % (i + 2) == 0:
			return False
	return True
for _ in range(int(input())):
	d = int(input())
	l = []
	b = 1 + d
	while not fun(b):
		b += 1
	l.append(b)
	b += d
	while not fun(b):
		b += 1
	l.append(b)
	print(l[0] * l[1])


import sys
import math
import collections
import bisect
import string

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()

def print_primes_till_N(N):
	(i, j, flag) = (0, 0, 0)
	ans = []
	for i in range(1, N + 1, 1):
		if i == 1 or i == 0:
			continue
		flag = 1
		for j in range(2, i // 2 + 1, 1):
			if i % j == 0:
				flag = 0
				break
		if flag == 1:
			ans.append(i)
	return ans
prime = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001, 16007, 16033, 16057, 16061, 16063, 16067, 16069, 16073, 16087, 16091, 16097, 16103, 16111, 16127, 16139, 16141, 16183, 16187, 16189, 16193, 16217, 16223, 16229, 16231, 16249, 16253, 16267, 16273, 16301, 16319, 16333, 16339, 16349, 16361, 16363, 16369, 16381, 16411, 16417, 16421, 16427, 16433, 16447, 16451, 16453, 16477, 16481, 16487, 16493, 16519, 16529, 16547, 16553, 16561, 16567, 16573, 16603, 16607, 16619, 16631, 16633, 16649, 16651, 16657, 16661, 16673, 16691, 16693, 16699, 16703, 16729, 16741, 16747, 16759, 16763, 16787, 16811, 16823, 16829, 16831, 16843, 16871, 16879, 16883, 16889, 16901, 16903, 16921, 16927, 16931, 16937, 16943, 16963, 16979, 16981, 16987, 16993, 17011, 17021, 17027, 17029, 17033, 17041, 17047, 17053, 17077, 17093, 17099, 17107, 17117, 17123, 17137, 17159, 17167, 17183, 17189, 17191, 17203, 17207, 17209, 17231, 17239, 17257, 17291, 17293, 17299, 17317, 17321, 17327, 17333, 17341, 17351, 17359, 17377, 17383, 17387, 17389, 17393, 17401, 17417, 17419, 17431, 17443, 17449, 17467, 17471, 17477, 17483, 17489, 17491, 17497, 17509, 17519, 17539, 17551, 17569, 17573, 17579, 17581, 17597, 17599, 17609, 17623, 17627, 17657, 17659, 17669, 17681, 17683, 17707, 17713, 17729, 17737, 17747, 17749, 17761, 17783, 17789, 17791, 17807, 17827, 17837, 17839, 17851, 17863, 17881, 17891, 17903, 17909, 17911, 17921, 17923, 17929, 17939, 17957, 17959, 17971, 17977, 17981, 17987, 17989, 18013, 18041, 18043, 18047, 18049, 18059, 18061, 18077, 18089, 18097, 18119, 18121, 18127, 18131, 18133, 18143, 18149, 18169, 18181, 18191, 18199, 18211, 18217, 18223, 18229, 18233, 18251, 18253, 18257, 18269, 18287, 18289, 18301, 18307, 18311, 18313, 18329, 18341, 18353, 18367, 18371, 18379, 18397, 18401, 18413, 18427, 18433, 18439, 18443, 18451, 18457, 18461, 18481, 18493, 18503, 18517, 18521, 18523, 18539, 18541, 18553, 18583, 18587, 18593, 18617, 18637, 18661, 18671, 18679, 18691, 18701, 18713, 18719, 18731, 18743, 18749, 18757, 18773, 18787, 18793, 18797, 18803, 18839, 18859, 18869, 18899, 18911, 18913, 18917, 18919, 18947, 18959, 18973, 18979, 19001, 19009, 19013, 19031, 19037, 19051, 19069, 19073, 19079, 19081, 19087, 19121, 19139, 19141, 19157, 19163, 19181, 19183, 19207, 19211, 19213, 19219, 19231, 19237, 19249, 19259, 19267, 19273, 19289, 19301, 19309, 19319, 19333, 19373, 19379, 19381, 19387, 19391, 19403, 19417, 19421, 19423, 19427, 19429, 19433, 19441, 19447, 19457, 19463, 19469, 19471, 19477, 19483, 19489, 19501, 19507, 19531, 19541, 19543, 19553, 19559, 19571, 19577, 19583, 19597, 19603, 19609, 19661, 19681, 19687, 19697, 19699, 19709, 19717, 19727, 19739, 19751, 19753, 19759, 19763, 19777, 19793, 19801, 19813, 19819, 19841, 19843, 19853, 19861, 19867, 19889, 19891, 19913, 19919, 19927, 19937, 19949, 19961, 19963, 19973, 19979, 19991, 19993, 19997, 20011, 20021, 20023, 20029, 20047, 20051, 20063, 20071, 20089, 20101, 20107, 20113, 20117, 20123, 20129, 20143, 20147, 20149, 20161, 20173, 20177, 20183, 20201, 20219, 20231, 20233, 20249, 20261, 20269, 20287, 20297, 20323, 20327, 20333, 20341, 20347, 20353, 20357, 20359, 20369, 20389, 20393, 20399, 20407, 20411, 20431, 20441, 20443, 20477, 20479, 20483, 20507, 20509, 20521, 20533, 20543, 20549, 20551, 20563, 20593, 20599, 20611, 20627, 20639, 20641, 20663, 20681, 20693, 20707, 20717, 20719, 20731, 20743, 20747, 20749, 20753, 20759, 20771, 20773, 20789, 20807, 20809, 20849, 20857, 20873, 20879, 20887, 20897, 20899, 20903, 20921, 20929, 20939, 20947, 20959, 20963, 20981, 20983, 21001, 21011, 21013, 21017, 21019, 21023, 21031, 21059, 21061, 21067, 21089, 21101, 21107, 21121, 21139, 21143, 21149, 21157, 21163, 21169, 21179, 21187, 21191, 21193, 21211, 21221, 21227, 21247, 21269, 21277, 21283, 21313, 21317, 21319, 21323, 21341, 21347, 21377, 21379, 21383, 21391, 21397, 21401, 21407, 21419, 21433, 21467, 21481, 21487, 21491, 21493, 21499, 21503, 21517, 21521, 21523, 21529, 21557, 21559, 21563, 21569, 21577, 21587, 21589, 21599, 21601, 21611, 21613, 21617, 21647, 21649, 21661, 21673, 21683, 21701, 21713, 21727, 21737, 21739, 21751, 21757, 21767, 21773, 21787, 21799, 21803, 21817, 21821, 21839, 21841, 21851, 21859, 21863, 21871, 21881, 21893, 21911, 21929, 21937, 21943, 21961, 21977, 21991, 21997, 22003, 22013, 22027, 22031, 22037, 22039, 22051, 22063, 22067, 22073, 22079, 22091, 22093, 22109, 22111, 22123, 22129, 22133, 22147, 22153, 22157, 22159, 22171, 22189, 22193, 22229, 22247, 22259, 22271, 22273, 22277, 22279, 22283, 22291, 22303, 22307, 22343, 22349, 22367, 22369, 22381, 22391, 22397, 22409, 22433, 22441, 22447, 22453, 22469, 22481, 22483, 22501, 22511, 22531, 22541, 22543, 22549, 22567, 22571, 22573, 22613, 22619, 22621, 22637, 22639, 22643, 22651, 22669, 22679, 22691, 22697, 22699, 22709, 22717, 22721, 22727, 22739, 22741, 22751, 22769, 22777, 22783, 22787, 22807, 22811, 22817, 22853, 22859, 22861, 22871, 22877, 22901, 22907, 22921, 22937, 22943, 22961, 22963, 22973, 22993, 23003, 23011, 23017, 23021, 23027, 23029, 23039, 23041, 23053, 23057, 23059, 23063, 23071, 23081, 23087, 23099, 23117, 23131, 23143, 23159, 23167, 23173, 23189, 23197, 23201, 23203, 23209, 23227, 23251, 23269, 23279, 23291, 23293, 23297, 23311, 23321, 23327, 23333, 23339, 23357, 23369, 23371, 23399, 23417, 23431, 23447, 23459, 23473, 23497, 23509, 23531, 23537, 23539, 23549, 23557, 23561, 23563, 23567, 23581, 23593, 23599, 23603, 23609, 23623, 23627, 23629, 23633, 23663, 23669, 23671, 23677, 23687, 23689, 23719, 23741, 23743, 23747, 23753, 23761, 23767, 23773, 23789, 23801, 23813, 23819, 23827, 23831, 23833, 23857, 23869, 23873, 23879, 23887, 23893, 23899, 23909, 23911, 23917, 23929, 23957, 23971, 23977, 23981, 23993, 24001, 24007, 24019, 24023, 24029, 24043, 24049, 24061, 24071, 24077, 24083, 24091, 24097, 24103, 24107, 24109, 24113, 24121, 24133, 24137, 24151, 24169, 24179, 24181, 24197, 24203, 24223, 24229, 24239, 24247, 24251, 24281, 24317, 24329, 24337, 24359, 24371, 24373, 24379, 24391, 24407, 24413, 24419, 24421, 24439, 24443, 24469, 24473, 24481, 24499, 24509, 24517, 24527, 24533, 24547, 24551, 24571, 24593, 24611, 24623, 24631, 24659, 24671, 24677, 24683, 24691, 24697, 24709, 24733, 24749, 24763, 24767, 24781, 24793, 24799, 24809, 24821, 24841, 24847, 24851, 24859, 24877, 24889, 24907, 24917, 24919, 24923, 24943, 24953, 24967, 24971, 24977, 24979, 24989, 25013, 25031, 25033, 25037, 25057, 25073, 25087, 25097, 25111, 25117, 25121, 25127, 25147, 25153, 25163, 25169, 25171, 25183, 25189, 25219, 25229, 25237, 25243, 25247, 25253, 25261, 25301, 25303, 25307, 25309, 25321, 25339, 25343, 25349, 25357, 25367, 25373, 25391, 25409, 25411, 25423, 25439, 25447, 25453, 25457, 25463, 25469, 25471, 25523, 25537, 25541, 25561, 25577, 25579, 25583, 25589, 25601, 25603, 25609, 25621, 25633, 25639, 25643, 25657, 25667, 25673, 25679, 25693, 25703, 25717, 25733, 25741, 25747, 25759, 25763, 25771, 25793, 25799, 25801, 25819, 25841, 25847, 25849, 25867, 25873, 25889, 25903, 25913, 25919, 25931, 25933, 25939, 25943, 25951, 25969, 25981, 25997, 25999, 26003, 26017, 26021, 26029, 26041, 26053, 26083, 26099, 26107, 26111, 26113, 26119, 26141, 26153, 26161, 26171, 26177, 26183, 26189, 26203, 26209, 26227, 26237, 26249, 26251, 26261, 26263, 26267, 26293, 26297, 26309, 26317, 26321, 26339, 26347, 26357, 26371, 26387, 26393, 26399, 26407, 26417, 26423, 26431, 26437, 26449, 26459, 26479, 26489, 26497, 26501, 26513, 26539, 26557, 26561, 26573, 26591, 26597, 26627, 26633, 26641, 26647, 26669, 26681, 26683, 26687, 26693, 26699, 26701, 26711, 26713, 26717, 26723, 26729, 26731, 26737, 26759, 26777, 26783, 26801, 26813, 26821, 26833, 26839, 26849, 26861, 26863, 26879, 26881, 26891, 26893, 26903, 26921, 26927, 26947, 26951, 26953, 26959, 26981, 26987, 26993, 27011, 27017, 27031, 27043, 27059, 27061, 27067, 27073, 27077, 27091, 27103, 27107, 27109, 27127, 27143, 27179, 27191, 27197, 27211, 27239, 27241, 27253, 27259, 27271, 27277, 27281, 27283, 27299, 27329, 27337, 27361, 27367, 27397, 27407, 27409, 27427, 27431, 27437, 27449, 27457, 27479, 27481, 27487, 27509, 27527, 27529, 27539, 27541, 27551, 27581, 27583, 27611, 27617, 27631, 27647, 27653, 27673, 27689, 27691, 27697, 27701, 27733, 27737, 27739, 27743, 27749, 27751, 27763, 27767, 27773, 27779, 27791, 27793, 27799, 27803, 27809, 27817, 27823, 27827, 27847, 27851, 27883, 27893, 27901, 27917, 27919, 27941, 27943, 27947, 27953, 27961, 27967, 27983, 27997, 28001, 28019, 28027, 28031, 28051, 28057, 28069, 28081, 28087, 28097, 28099, 28109, 28111, 28123, 28151, 28163, 28181, 28183, 28201, 28211, 28219, 28229, 28277, 28279, 28283, 28289, 28297, 28307, 28309, 28319, 28349, 28351, 28387, 28393, 28403, 28409, 28411, 28429, 28433, 28439, 28447, 28463, 28477, 28493, 28499, 28513, 28517, 28537, 28541, 28547, 28549, 28559, 28571, 28573, 28579, 28591, 28597, 28603, 28607, 28619, 28621, 28627, 28631, 28643, 28649, 28657, 28661, 28663, 28669, 28687, 28697, 28703, 28711, 28723, 28729, 28751, 28753, 28759, 28771, 28789, 28793, 28807, 28813, 28817, 28837, 28843, 28859, 28867, 28871, 28879, 28901, 28909, 28921, 28927, 28933, 28949, 28961, 28979, 29009, 29017, 29021, 29023, 29027, 29033, 29059, 29063, 29077, 29101, 29123, 29129, 29131, 29137, 29147, 29153, 29167, 29173, 29179, 29191, 29201, 29207, 29209, 29221, 29231, 29243, 29251, 29269, 29287, 29297, 29303, 29311, 29327, 29333, 29339, 29347, 29363, 29383, 29387, 29389, 29399, 29401, 29411, 29423, 29429, 29437, 29443, 29453, 29473, 29483, 29501, 29527, 29531, 29537, 29567, 29569, 29573, 29581, 29587, 29599, 29611, 29629, 29633, 29641, 29663, 29669, 29671, 29683, 29717, 29723, 29741, 29753, 29759, 29761, 29789, 29803, 29819, 29833, 29837, 29851, 29863, 29867, 29873, 29879, 29881, 29917, 29921, 29927, 29947, 29959, 29983, 29989]
for t in range(int(input())):
	d = int(input())
	f = 1
	no_1 = prime[bisect.bisect_left(prime, f + d)]
	no_2 = prime[bisect.bisect_left(prime, no_1 + d)]
	print(no_1 * no_2)


T = int(input())
MAX_P = 40000
primes = [False] + [True] * MAX_P
plist = []
for (i, p) in enumerate(primes):
	if not p:
		continue
	if i == 1:
		continue
	plist.append(i)
	if i ** 2 > MAX_P:
		continue
	j = i
	while i * j <= MAX_P:
		primes[i * j] = False
		j += 1

def bs(x, i, j):
	if j == i + 1:
		return plist[i]
	m = (i + j - 1) // 2
	if plist[m] >= x:
		return bs(x, i, m + 1)
	return bs(x, m + 1, j)

def do(N):
	p = bs(N + 1, 0, len(plist))
	q = bs(p + N, 0, len(plist))
	return min(p ** 3, p * q)
for _ in range(T):
	N = int(input())
	print(do(N))


x = 500001
lst = [1] * (x + 1)
lst[1] = 0
t = int(x ** 0.5) + 1
if x == 1:
	print()
else:
	for i in range(2, t + 1):
		if lst[i] == 1:
			for j in range(i * i, x + 1, i):
				lst[j] = 0
for y in range(int(input())):
	n = int(input())
	i = n + 1
	while lst[i] == 0:
		i += 1
	a = i
	i = i + n
	while lst[i] == 0:
		i += 1
	print(a * i)


import sys
import io, os
input = sys.stdin.buffer.readline
t = int(input())
import math

def sieve(n):
	ass = []
	is_prime = [True] * (n + 1)
	is_prime[0] = False
	is_prime[1] = False
	for i in range(2, int(math.sqrt(n)) + 1):
		if not is_prime[i]:
			continue
		for j in range(i * 2, n + 1, i):
			is_prime[j] = False
	for i in range(n + 1):
		if is_prime[i]:
			ass.append(i)
	return ass
S = sieve(10 ** 5)
import bisect
for _ in range(t):
	d = int(input())
	i = bisect.bisect_left(S, d + 1)
	p = S[i]
	j = bisect.bisect_left(S, p + d)
	q = S[j]
	print(p * q)


def isprime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True
for _ in range(int(input())):
	d = int(input())
	p = d + 1
	while not isprime(p):
		p += 1
	q = p + d
	while True:
		if isprime(q):
			ans = q
			break
		if q > p * p:
			ans = p * p
			break
		q += 1
	print(p * q)


def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
t = int(input())
for i in range(t):
	d = int(input())
	l = []
	g = 1
	while len(l) != 1:
		if isPrime(d + g):
			l.append(d + g)
		g += 1
	z = 0
	while len(l) != 2:
		if isPrime(l[0] + d + z):
			l.append(l[0] + d + z)
		z += 1
	print(l[0] * l[1])
	l = []


import math
import random
from collections import *
mod = 1000000007
r1 = lambda : int(input())
rm = lambda : map(int, input().split())
rms = lambda : map(str, input().split())
rls = lambda : list(rm())

def check(ls):
	ls[0] = 1
	ret = [1]
	for i in range(2, 1000000):
		if ls[i] == 0:
			ret.append(i)
			for j in range(i + i, 1000000, i):
				ls[j] = 1
	return ret

def find(ls, d):
	for i in ls:
		if i >= d:
			return i
	return -1

def solve():
	prime = [0] * 1000000
	prime = check(prime)
	test = r1()
	while test:
		test -= 1
		d = r1()
		ans = 1
		temp = find(prime, d + 1)
		temp2 = find(prime, temp + d)
		print(temp * temp2)

def def_value():
	return 'nan'
solve()


import time, math as mt, bisect as bs, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi = 3.141592653589793

def II():
	return int(stdin.readline())

def IP():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count
mx = 10 ** 7
spf = [mx] * (mx + 1)

def readTree(n, e):
	adj = [set() for i in range(n + 1)]
	for i in range(e):
		(u1, u2) = IP()
		adj[u1].add(u2)
	return adj

def sieve(n):
	li = [True] * n
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	prime = deque()
	for i in range(n):
		if li[i] == True:
			prime.append(i)
	return prime

def SPF():
	mx = 10 ** 6 + 1
	spf[1] = 1
	for i in range(2, mx):
		if spf[i] == 1000000000.0:
			spf[i] = i
			for j in range(i * i, mx, i):
				if i < spf[j]:
					spf[j] = i
	return

def prime(n, d):
	prm = set()
	while n != 1:
		prm.add(spf[n])
		n = n // spf[n]
	for ele in prm:
		d[ele] = d.get(ele, 0) + 1
	return
mod = 998244353
inf = 10000000000000000

def solve(prime):
	d = II()
	num1 = 1 + d
	num2 = 0
	ans = 1
	for ele in prime:
		if ele >= num1:
			ans *= ele
			num2 = ele + d
			break
	for ele in prime:
		if ele >= num2:
			ans *= ele
			break
	print(ans)
	return
t = II()
prime = sieve(100000)
for i in range(t):
	solve(prime)


a = []

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			a.append(p)

def sum(a, b):
	return a + b

def solve(d):
	a1 = 0
	a2 = 0
	i = 0
	while a[i] < 1 + d:
		i += 1
	a1 = a[i]
	while a[i] < a1 + d:
		i += 1
	a2 = a[i]
	print(a1 * a2)
SieveOfEratosthenes(1000000)
for i in range(int(input())):
	d = int(input())
	solve(d)


N = 10 ** 5
is_prime = [1] * N
is_prime[0] = 0
is_prime[1] = 0

def sieve():
	i = 2
	while i * i <= N:
		if is_prime[i] == 0:
			i += 1
			continue
		j = 2 * i
		while j < N:
			is_prime[j] = 0
			j += i
		i += 1
sieve()

def nextPrime(n):
	i = n
	while True:
		if is_prime[i]:
			return i
		i += 1
for _ in range(int(input())):
	d = int(input())
	k1 = nextPrime(d + 1)
	k2 = nextPrime(d + k1)
	print(k1 * k2)


def all_prime(n):
	dicti = {}
	dicti[0] = 0
	dicti[1] = 0
	for i in range(2, n):
		if i not in dicti:
			dicti[i] = 1
			j = 2 * i
			while j <= n:
				dicti[j] = 0
				j += i
	return dicti
dicti = all_prime(22000)
for i in range(int(input())):
	d = int(input())
	v = []
	v.append(1)
	sam = 1 + d
	while True:
		if len(v) == 3:
			break
		if dicti[sam] == 1:
			v.append(sam)
			sam += d
		else:
			sam += 1
	print(v[1] * v[2])


n = 20011
arr = [True for _ in range(n + 1)]
for x in range(2, n + 1):
	if arr[x]:
		z = 2
		l = n // x
		while z <= l:
			tmp = x * z
			if arr[tmp]:
				arr[tmp] = False
			z += 1
for _ in range(int(input())):
	d = int(input())
	ans = 1
	for x in range(1 + d, n + 1):
		if arr[x]:
			ans *= x
			break
	for x in range(ans + d, n + 1):
		if arr[x]:
			ans *= x
			break
	print(ans)


MAXPRIME = 20012
isPrime = [0 for _ in range(MAXPRIME + 1)]
isPrime[0] = -1
isPrime[1] = -1
for i in range(2, MAXPRIME // 2 + 1):
	if isPrime[i] == 0:
		for multiple in range(i * i, MAXPRIME + 1, i):
			if isPrime[multiple] == 0:
				isPrime[multiple] = i
primeNumberSet = set()
for i in range(len(isPrime)):
	if isPrime[i] == 0:
		primeNumberSet.add(i)
pList = list(sorted(primeNumberSet))

def main():
	n = len(primeNumberSet)
	t = int(input())
	allAns = []
	for _ in range(t):
		d = int(input())
		f1 = 1
		i = -1
		b = 2263
		while b > 0:
			while i + b < n and pList[i + b] < f1 + d:
				i += b
			b //= 2
		f2 = pList[i + 1]
		i = -1
		b = 2263
		while b > 0:
			while i + b < n and pList[i + b] < f2 + d:
				i += b
			b //= 2
		f3 = pList[i + 1]
		ans = f1 * f2 * f3
		allAns.append(ans)
	multiLineArrayPrint(allAns)
	return
import sys
input = sys.stdin.buffer.readline

def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def multiLineArrayPrint(arr):
	print('\n'.join([str(x) for x in arr]))

def multiLineArrayOfArraysPrint(arr):
	print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

def readIntArr():
	return [int(x) for x in input().split()]
inf = float('inf')
MOD = 10 ** 9 + 7
main()


import sys
input = sys.stdin.readline
n = 30000
p = []
arr = [True for i in range(n)]
i = 2
while i < n:
	if arr[i] == True:
		p.append(i)
		curr = 2 * i
		while curr < n:
			arr[curr] = False
			curr += i
	i += 1
l = len(p)
for _ in range(int(input())):
	n = int(input())
	ans = -1
	for i in range(l):
		f = True
		if p[i] - 1 >= n:
			for j in range(i + 1, l):
				if p[j] - p[i] >= n:
					ans = p[i] * p[j]
					f = False
					break
		if f == False:
			break
	print(ans)


import sys

def primes(n):
	i = 2
	prime = [True] * n
	prime[0] = prime[1] = False
	while i * i < n:
		if prime[i]:
			j = i + i
			while j < n:
				prime[j] = False
				j += i
		i += 1
	return prime

def solve(x, prime):
	p = x + 1
	while not prime[p]:
		p += 1
	q = p + x
	while not prime[q]:
		q += 1
	return p * q
n = int(input())
p = primes(int(100000.0))
for _ in range(n):
	x = int(input())
	print(solve(x, p))


def sieve(n):
	isPrime = [True] * (n + 1)
	isPrime[0] = False
	isPrime[1] = False
	p = 2
	while p * p <= n:
		if isPrime[p]:
			for j in range(p * p, n + 1, p):
				isPrime[j] = False
		p += 1
	return isPrime
prime = sieve(100000)
for _ in range(int(input())):
	d = int(input())
	m = 100001
	x = d + 1
	ans = 1
	for i in range(x, m):
		if prime[i]:
			ans *= i
			break
	for i in range(ans + d, m):
		if prime[i]:
			ans *= i
			break
	print(ans)


N = 20020
a = [1] * N
i = 2
while i * i < N:
	j = i * i
	if a[i]:
		while j < N:
			a[j] = 0
			j += i
	i += 1
for s in [*open(0)][1:]:
	d = int(s)
	i = a.index(1, d + 1)
	print(i * a.index(1, i + d))


def primes():
	a = [0 for i in range(50000)]
	a[0] = 1
	for i in range(1, 50000):
		if a[i] == 0:
			j = 2 * i + 1
			while j < 50000:
				a[j] = 1
				j += i + 1
		else:
			continue
	a = [i + 1 for i in range(50000) if a[i] == 0]
	return a
r = primes()

def dico(l, x):
	(i, j) = (0, len(l) - 1)
	while i <= j:
		ind = (i + j) // 2
		if l[ind] == x:
			i = ind
			break
		elif l[ind] < x:
			i = ind + 1
		else:
			j = ind - 1
	return i

def divis(r, d):
	a = dico(r, d + 1)
	b = dico(r, r[a] + d)
	return r[a] * r[b]
for _ in range(int(input())):
	d = int(input())
	print(divis(r, d))


import os
import sys
from io import BytesIO, IOBase
from math import gcd, inf, sqrt

def lcm(a, b):
	return a * b // gcd(a, b)

def getFactorization(x):
	ret = list()
	while x != 1:
		ret.append(spf[x])
		x = x // spf[x]
	return ret

def printDivisors(n):
	i = 2
	z = [1, n]
	while i <= sqrt(n):
		if n % i == 0:
			if n / i == i:
				z.append(i)
			else:
				z.append(i)
				z.append(n // i)
		i = i + 1
	return z

def cheaker(a):
	j = 1
	p = False
	for i in a:
		if i != j:
			break
		j += 1
	q = len(a)
	for i in a[::-1]:
		if i != q:
			break
		q -= 1
	for i in range(j - 1, q):
		if a[i] == i + 1:
			return False
	return True

def create(n, x, f):
	pq = len(bin(n)[2:])
	if f == 0:
		tt = min
	else:
		tt = max
	dp = [[inf] * n for _ in range(pq)]
	dp[0] = x
	for i in range(1, pq):
		for j in range(n - (1 << i) + 1):
			dp[i][j] = tt(dp[i - 1][j], dp[i - 1][j + (1 << i - 1)])
	return dp

def enquiry(l, r, dp, f):
	if l > r:
		return inf if not f else -inf
	if f == 1:
		tt = max
	else:
		tt = min
	pq1 = len(bin(r - l + 1)[2:]) - 1
	return tt(dp[pq1][l], dp[pq1][r - (1 << pq1) + 1])

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	x = []
	for i in range(2, n + 1):
		if prime[i]:
			x.append(i)
	return x

def main():
	z = SieveOfEratosthenes(100001)
	an = []
	for _ in range(int(input())):
		d = int(input())
		an = [1]
		for i in range(len(z)):
			if z[i] >= d + 1:
				an.append(i)
				break
		for i in range(an[-1] + 1, len(z)):
			if z[i] - z[an[-1]] >= d:
				an[-1] = z[an[-1]]
				an.append(z[i])
				break
		an.append(an[-1] * an[-2])
		print(an[-1])
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import math

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	for i in range(5, int(math.sqrt(n) + 1), 6):
		if n % i == 0 or n % (i + 2) == 0:
			return False
	return True

def nextPrime(N):
	if isPrime(N) == True:
		return N
	if N <= 1:
		return 2
	prime = N
	found = False
	while not found:
		prime = prime + 1
		if isPrime(prime) == True:
			found = True
	return prime
for test in range(int(input())):
	d = int(input())
	y = nextPrime(1 + d)
	z = nextPrime(y + d)
	print(y * z)


from sys import stdin
input = stdin.readline

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
for _ in range(int(input())):
	n = int(input())
	a = 1 + n
	while not isPrime(a):
		a += 1
	b = a + n
	while not isPrime(b):
		b += 1
	print(a * b)


from bisect import *
n = 10 ** 5
i = 2
p = [1] * (n + 1)
while i * i <= n:
	if p[i]:
		j = i * i
		while j <= n:
			p[j] = 0
			j += i
	i += 1
b = []
for i in range(2, n + 1):
	if p[i]:
		b.append(i)
for _ in range(int(input())):
	d = int(input())
	z = bisect_left(b, d + 1)
	y = bisect_left(b, b[z] + d)
	print(b[z] * b[y])


def prime(m):
	for i in range(2, m):
		if m % i == 0:
			return False
	return True
for _ in range(int(input())):
	d = int(input())
	x = 1
	ans = 1
	for i in range(x + d, 10 ** 9):
		if prime(i):
			x = i
			ans *= x
			break
	for i in range(x + d, 10 ** 9):
		if prime(i):
			x = i
			ans *= x
			break
	print(ans)


pr = []
N = 10000 * 3
s = [0] * N
for i in range(2, N):
	if s[i]:
		continue
	pr.append(i)
	for j in range(2 * i, N, i):
		s[j] = 1
gans = []
for _ in range(int(input())):
	d = int(input())
	a = b = 0
	for i in range(len(pr) - 1):
		if pr[i] > d:
			if a == 0:
				a = pr[i]
				d = a + d - 1
			else:
				b = pr[i]
				break
	gans.append(a * b)
print('\n'.join(map(str, gans)))


def pc(n):
	if n % 2 == 0 and n != 2:
		return 0
	if n == 2:
		return 1
	for i in range(3, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			return 0
	return 1
for _ in range(int(input())):
	x = int(input())
	i = 1 + x
	out = 1
	c = 0
	while True:
		if pc(i) == 1:
			out = out * i
			c = c + 1
			i = i + x
			if c == 2:
				break
		else:
			i = i + 1
	print(out)


def SieveOfEratosthenes(n):
	a = []
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			a.append(p)
	return a

def bs(a, x, start, end):
	if start > end:
		return -1
	if start == end:
		return a[start]
	mid = start + (end - start) // 2
	if a[mid] == x:
		return x
	elif x < a[mid]:
		return bs(a, x, start, mid)
	else:
		return bs(a, x, mid + 1, end)
n = 25000
a = SieveOfEratosthenes(n)
l = len(a)
for _ in range(int(input())):
	d = int(input())
	p1 = bs(a, 1 + d, 0, l - 1)
	p2 = bs(a, p1 + d, 0, l - 1)
	print(p1 * p2)


l = []

def SieveOfEratosthenes(n):
	l = []
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			l.append(p)
	return l

def binSearch(sc, lf, r):
	if lf == r - 1 and sc != l[lf] and (sc != l[r]):
		return r
	if lf < r:
		mid = (lf + r) // 2
		if l[mid] == sc:
			return mid
		elif l[mid] > sc:
			return binSearch(sc, lf, mid)
		else:
			return binSearch(sc, mid, r)
	return r
MAX = 100000
l = SieveOfEratosthenes(MAX)
for _ in range(int(input())):
	d = int(input())
	k = binSearch(1 + d, 0, len(l) - 1)
	p = binSearch(d + l[k], 0, len(l) - 1)
	print(l[k] * l[p])


def is_prime(n):
	if n <= 1:
		return False
	elif n <= 3:
		return True
	elif n % 2 == 0 or n % 3 == 0:
		return False
	k = 5
	while k * k <= n:
		if n % k == 0 or n % (k + 2) == 0:
			return False
		k += 6
	return True
t = int(input())
for i in range(t):
	n = int(input())
	k = n + 1
	while True:
		if is_prime(k):
			break
		else:
			k += 1
	a = k + n
	while True:
		if is_prime(a):
			break
		else:
			a += 1
	print(k * a)


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
from decimal import *
BUFSIZE = 8192
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	t = int(input())
	prime = []

	def isprime(n):
		if n <= 1:
			return 0
		m = int(math.sqrt(n)) + 1
		for x in range(2, m):
			if n % x == 0:
				return 0
		return 1
	for i in range(2, 10 ** 5 + 1):
		if isprime(i) == 1:
			prime.append(i)
	for i in range(t):
		d = int(input())
		l = bisect.bisect_left(prime, 1 + d)
		if prime[l] < 1 + d:
			l += 1
		r = bisect.bisect_left(prime, prime[l] + d)
		if prime[r] < prime[l] + d:
			r += 1
		print(prime[l] * prime[r])
main()


import math
from itertools import compress

def prime_sieve(limit):
	if limit < 2:
		return []
	limit += 1
	primes = [True] * limit
	for base in range(2, int(limit ** 0.5 + 1)):
		if primes[base]:
			primes[base * 2:limit:base] = [False] * (math.ceil(limit / base) - 2)
	primes[0] = primes[1] = False
	return compress(range(limit), primes)
s = list(prime_sieve(100000))

def sol(n):
	a = 1 + n
	for i in s:
		if i >= a:
			a = i
			break
	b = a + n
	for i in s:
		if i >= b:
			b = i
			break
	return a * b
t = int(input())
while t != 0:
	d = int(input())
	print(sol(d))
	t -= 1


def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	out = []
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = False
	prime[1] = False
	for p in range(n + 1):
		if prime[p]:
			out.append(p)
	return out
arr = SieveOfEratosthenes(10 ** 5)
import bisect
for _ in range(int(input())):
	n = int(input())
	a = bisect.bisect_left(arr, 1 + n)
	out = arr[a]
	b = bisect.bisect_left(arr, out + n)
	out *= arr[b]
	print(out)


import sys, math
input = sys.stdin.readline

def isPrime(x):
	if x == 2:
		return True
	sq = math.ceil(math.sqrt(x))
	for i in range(2, sq + 1):
		if x % i == 0:
			return False
	return True
for _ in range(int(input())):
	d = int(input())
	start = 1 + d
	while not isPrime(start):
		start += 1
	c = start
	start += d
	while not isPrime(start):
		start += 1
	print(c * start)


a = [1] * 8 ** 5
i = 2
while (b := ([0] * -(-8 ** 5 // i + i))):
	a[i * i::i] = b
	i += 1
for s in [*open(0)][1:]:
	d = int(s)
	i = a.index(1, d + 1)
	print(i * a.index(1, i + d))


mod = 998244353

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
tt = int(input())
prime = SieveOfEratosthenes(1000000)
for _ in range(tt):
	pre = 1
	ans = 1
	n = int(input())
	c = 2
	while c < 4:
		for i in range(2, len(prime)):
			if i - pre >= n:
				if prime[i] == True:
					ans *= i
					c += 1
					pre = i
				if c == 4:
					break
	print(ans)


rn = lambda : int(input())
rl = lambda : list(map(int, input().split()))
rns = lambda : map(int, input().split())
rs = lambda : input()
yn = lambda x: print('Yes') if x else print('No')
YN = lambda x: print('YES') if x else print('NO')
sieve = 20012 * [0]
primes = []
for i in range(2, len(sieve)):
	if sieve[i] == 0:
		primes.append(i)
		for j in range(i, len(sieve), i):
			sieve[j] = 1
for _ in range(rn()):
	d = rn()
	from bisect import bisect_left
	a = primes[bisect_left(primes, 1 + d)]
	b = primes[bisect_left(primes, a + d)]
	print(a * b)


def notdivisible(a):
	for i in range(2, a):
		if a % i == 0:
			return False
	return True
for _ in range(int(input())):
	d = int(input())
	x = 1 + d
	while True:
		if notdivisible(x):
			break
		else:
			x += 1
	y = x + d
	while True:
		if notdivisible(y):
			break
		else:
			y += 1
	print(x * y)


def fun():
	prime = [True for i in range(30000)]
	p = 2
	while p * p <= 30000:
		if prime[p] == True:
			for i in range(p * p, 30000, p):
				prime[i] = False
		p += 1
	for _ in range(int(input())):
		d = int(input())
		c = -1
		for i in range(1 + d, 30000):
			if prime[i]:
				c = i
				break
		e = -1
		for i in range(c + d, 30000):
			if prime[i]:
				e = i
				break
		print(c * e)
fun()


from bisect import bisect_left

def A1():
	for test in range(int(input())):
		(n, d) = [int(num) for num in input().split()]
		nums = [int(num) for num in input().split()]
		maxNum = max(nums)
		minNum1 = min(nums)
		nums.remove(minNum1)
		minNum2 = min(nums)
		if maxNum <= d or minNum1 + minNum2 <= d:
			print('Yes')
		else:
			print('No')

def A2():
	for test in range(int(input())):
		n = int(input())
		b = input()
		a = ''
		last = None
		for digit in b:
			if 1 + int(digit) != last:
				a += '1'
				last = 1 + int(digit)
			else:
				a += '0'
				last = 0 + int(digit)
		print(a)

def SieveOfErastotenes(n):
	primes = [True] * n
	p = 2
	while p * p <= n:
		if primes[p]:
			for i in range(p * 2, n, p):
				primes[i] = False
		p += 1
	primes[0] = False
	primes[1] = False
	return [p for p in range(n) if primes[p]]

def B(primes):
	for test in range(int(input())):
		d = int(input())
		p1 = primes[bisect_left(primes, d + 1)]
		p2 = primes[bisect_left(primes, p1 + d)]
		print(p1 * p2)
p = SieveOfErastotenes(200005)
B(p)

class A:

	def __init__(self, name):
		self.name = name

	def get_name(self):
		return self.name

	def __getitem__(self, key=3):
		return 3

	def __call__(self):
		print(self.name)

	def __len__(self):
		return 324234

class B(A):

	def __init__(self, name, surname):
		super(B, self).__init__(name)
		self.surname = surname

	def get_surname(self):
		return self.name


isprime = [1] * 20015
isprime[0] = isprime[1] = 0
for i in range(2, 20015):
	if i * i > 20015:
		break
	if isprime:
		for j in range(i * i, 20015, i):
			isprime[j] = 0
primes = []
for i in range(20015):
	if isprime[i]:
		primes.append(i)

def binsearch(d, x):
	l = 0
	r = len(primes)
	m = -1
	ans = -1
	while l <= r:
		m = l + (r - l) // 2
		if primes[m] - x >= d:
			ans = primes[m]
			r = m - 1
		else:
			l = m + 1
	return ans
n = int(input())
q = []
for i in range(n):
	q.append(int(input()))
for d in q:
	prime1 = binsearch(d, 1)
	prime2 = binsearch(d, prime1)
	print(prime1 * prime2)


from sys import stdin
from itertools import repeat

def prime():
	arr = list(repeat(True, 50000))
	for i in range(2, int(50000 ** 0.5) + 1):
		if arr[i]:
			for j in range(i + i, 50000, i):
				arr[j] = False
	(arr[0], arr[1]) = (False, False)
	return arr

def main():
	(isprime, out) = (prime(), list())
	inp = iter(stdin.read().split())
	for t in range(int(next(inp))):
		d = int(next(inp))
		for a in range(d + 1, 50000):
			if isprime[a]:
				break
		for b in range(a + d, 50000):
			if isprime[b]:
				break
		out.append(a * b)
	print(*out, sep='\n')
main()


for _ in range(int(input())):
	d = int(input())

	def isPrime(n):
		if n <= 1:
			return False
		for i in range(2, int(n ** 0.5) + 1):
			if n % i == 0:
				return False
		return True

	def findprime(n):
		m = 10 ** 9
		for i in range(n, m):
			if isPrime(i):
				return i
	first = 1
	sec = findprime(d + 1)
	third = findprime(sec + d)
	print(sec * third)


is_prime = [1] * 30000
for i in range(2, 30000):
	if is_prime[i]:
		for j in range(i * i, 30000, i):
			is_prime[j] = 0
n = int(input())
for i in range(n):
	m = int(input())
	a = 1 + m
	while is_prime[a] == 0:
		a += 1
	b = a + m
	while is_prime[b] == 0:
		b += 1
	print(a * b)


prime = [True for i in range(50001)]
pp = []

def SieveOfEratosthenes(n=50000):
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for i in range(50001):
		if prime[i]:
			pp.append(i)
SieveOfEratosthenes()
pp = pp[2:]

def bs(n):
	l = 0
	r = len(pp)
	res = 0
	while l <= r:
		mid = (l + r) // 2
		if pp[mid] >= n:
			res = pp[mid]
			r = mid - 1
		else:
			l = mid + 1
	return res
for _ in range(int(input())):
	d = int(input())
	d1 = bs(1 + d)
	d2 = bs(d1 + d)
	print(d1 * d2)


import bisect
t = int(input())
p = [1] * 30001
p[0] = p[1] = 0
for i in range(2, 30001):
	if p[i]:
		for j in range(i + i, 30001, i):
			p[j] = 0
p = [i for (i, v) in enumerate(p) if v]
for _ in range(t):
	n = int(input())
	f = 1 + n
	f = p[bisect.bisect_left(p, f)]
	s = f + n
	s = p[bisect.bisect_left(p, s)]
	print(f * s)


import math
maxm = 100001
primes = [True] * maxm

def seive():
	for i in range(2, int(math.sqrt(maxm))):
		if primes[i] == True:
			for j in range(i * i, maxm, i):
				primes[j] = False
seive()
for t in range(int(input())):
	d = int(input())
	x = -1
	y = -1
	for i in range(1 + d, maxm):
		if primes[i] == True:
			x = i
			break
	for i in range(x + d, maxm):
		if primes[i] == True:
			y = i
			break
	print(x * y)


def Sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p ** 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = False
	prime[1] = False
	return prime
prime = Sieve(100000)
for _ in range(int(input())):
	n = int(input())
	a = n + 1
	for i in range(a, len(prime)):
		if prime[i]:
			p = i
			break
	for i in range(p + n, len(prime)):
		if prime[i]:
			q = i
			break
	print(p * q)


def is_prime(n, primes):
	for prime in primes:
		if n % prime == 0:
			return False
	return True

def main():
	t = int(input())
	primes = [2]
	for i in range(3, 200, 2):
		if is_prime(i, primes) == True:
			primes.append(i)
	while t != 0:
		d = int(input())
		if d == 1:
			a = 2
		elif d % 2 == 0:
			a = 1 + d
		else:
			a = 2 + d
		while a not in primes:
			if a > primes[-1]:
				break
			a += 2
		if a > primes[-1]:
			while is_prime(a, primes) != True:
				a += 2
		if a == 2:
			b = 3
		elif d % 2 == 0:
			b = a + d
		else:
			b = a + d + 1
		while b not in primes:
			if b > primes[-1]:
				break
			b += 2
		if b > primes[-1]:
			while is_prime(b, primes) != True:
				b += 2
		print(a * b)
		t -= 1
main()


import math

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	lst = int(math.sqrt(n)) + 1
	for i in range(3, lst, 2):
		if n % i == 0:
			return False
	return True

def getPrime(n):
	if n == 2:
		return 2
	if n % 2 == 0:
		n += 1
	while True:
		if isPrime(n):
			return n
		n += 2
t = int(input())
for _ in range(t):
	d = int(input())
	a = getPrime(1 + d)
	b = getPrime(a + d)
	print(a * b)


resheto = [True for i in range(10000 * 3 + 2)]
resheto[0] = False
resheto[1] = False
for i in range(4, len(resheto), 2):
	resheto[i] = False
for i in range(3, int(len(resheto) ** (1 / 2)) + 1, 2):
	if resheto[i]:
		for j in range(i ** 2, len(resheto), i):
			resheto[j] = False
for i in range(int(input())):
	d = int(input())
	temp = 1
	for j in range(d + temp, len(resheto)):
		if resheto[j]:
			temp = j
			break
	for j in range(d + temp, len(resheto)):
		if resheto[j]:
			print(j * temp)
			break


import sys
input = lambda : sys.stdin.readline().strip()

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def ii():
	return int(input())

def fi():
	return float(input())

def si():
	return input().strip()
MAX = 10000
dp = [True] * (4 * MAX)
dp[0] = dp[1] = False
for i in range(2, 4 * MAX // 2 + 1):
	for j in range(i + i, 4 * MAX, i):
		dp[j] = False
for _ in range(ii()):
	d = ii()
	a = int(1000000000.0)
	i1 = d + 1
	while True:
		if dp[i1]:
			break
		i1 += 1
	i2 = i1 + d
	while True:
		if dp[i2]:
			break
		i2 += 1
	print(i1 * i2)


def solve(case):
	d = int(input())
	a = -1
	b = -1
	for i in range(1 + d, 10000000):
		f = 0
		if i == 2:
			a = 2
			break
		for j in range(2, int(i ** 0.5) + 1):
			if i % j == 0:
				f = 1
				break
			else:
				continue
		if f == 0:
			a = i
			break
	for i in range(a + d, 10000000):
		f = 0
		if i == 2:
			b = 2
			break
		for j in range(2, int(i ** 0.5) + 1):
			if i % j == 0:
				f = 1
				break
			else:
				continue
		if f == 0:
			b = i
			break
	print(a * b)
for _ in range(int(input())):
	solve(1)


from sys import stdin
import math
input = stdin.readline
MAX = 100000
primes = []

def Sieve():
	n = MAX
	nNew = int(math.sqrt(n))
	marked = [0] * int(n / 2 + 500)
	for i in range(1, int((nNew - 1) / 2) + 1):
		for j in range(i * (i + 1) << 1, int(n / 2) + 1, 2 * i + 1):
			marked[j] = 1
	primes.append(2)
	for i in range(1, int(n / 2) + 1):
		if marked[i] == 0:
			primes.append(2 * i + 1)

def binarySearch(left, right, n):
	if left <= right:
		mid = int((left + right) / 2)
		if mid == 0 or mid == len(primes) - 1:
			return mid
		if primes[mid] == n:
			return mid - 1
		if primes[mid] < n and primes[mid + 1] > n:
			return mid
		if n < primes[mid]:
			return binarySearch(left, mid - 1, n)
		else:
			return binarySearch(mid + 1, right, n)
	return 0
q = int(input())
Sieve()
for _ in range(q):
	d = int(input())
	i = binarySearch(0, len(primes) - 1, d + 1)
	if primes[i] < d + 1:
		i += 1
	a = primes[i]
	i = binarySearch(0, len(primes) - 1, d + a)
	if primes[i] < d + a:
		i += 1
	b = primes[i]
	print(a * b)


def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i += 6
	return True
T = int(input())
while T > 0:
	T = T - 1
	diff = int(input())
	a = 1
	b = a + diff
	if b % 2 == 0 and diff != 1:
		b += 1
	while True:
		if isPrime(b) and b - a >= diff:
			break
		b += 2
	c = b + diff
	if c % 2 == 0:
		c += 1
	while True:
		if isPrime(c) and c - b >= diff:
			break
		c += 2
	print(b * c)


import sys
flag = {}
q = [0, 0]
mm = 30000
p = []
for i in range(2, mm):
	q.append(len(p))
	if i in flag:
		continue
	p.append(i)
	j = 2
	while i * j <= mm:
		flag[i * j] = 1
		j += 1
T = int(sys.stdin.readline().strip())
while T > 0:
	T -= 1
	n = int(sys.stdin.readline().strip())
	a = p[q[1 + n]]
	b = p[q[a + n]]
	print(a * b)


import math
g = [0] * 20983
g.append(20983)
for j in range(20982, 1, -1):
	c = 0
	for k in range(2, int(math.sqrt(j)) + 2):
		if j % k == 0:
			c = c + 1
			break
	if c == 0:
		g[j] = j
	else:
		g[j] = g[j + 1]
for j in range(int(input())):
	n = int(input())
	if n == 1:
		print('6')
	else:
		print(g[1 + n] * g[n + g[1 + n]])


from bisect import bisect_left
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def prime_sieve(n):
	flag = n % 6 == 2
	sieve = bytearray((n // 3 + flag >> 3) + 1)
	for i in range(1, int(n ** 0.5) // 3 + 1):
		if not sieve[i >> 3] >> (i & 7) & 1:
			k = 3 * i + 1 | 1
			for j in range(k * k // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
			for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
	return sieve

def prime_list(n):
	res = []
	if n > 1:
		res.append(2)
	if n > 2:
		res.append(3)
	if n > 4:
		sieve = prime_sieve(n + 1)
		res.extend((3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not sieve[i >> 3] >> (i & 7) & 1))
	return res

def main():
	for _ in range(int(input())):
		d = int(input())
		a = primes[bisect_left(primes, d + 1)]
		b = primes[bisect_left(primes, d + a)]
		print(a * b)
primes = prime_list(100000)
main()