AtCoder Beginner Contest 096 - Five  Five Everywhere

Print a sequence a_1, a_2, ..., a_N whose length is N that satisfies the following conditions:

* a_i (1 \leq i \leq N) is a prime number at most 55 555.
* The values of a_1, a_2, ..., a_N are all different.
* In every choice of five different integers from a_1, a_2, ..., a_N, the sum of those integers is a composite number.



If there are multiple such sequences, printing any of them is accepted.

Constraints

* N is an integer between 5 and 55 (inclusive).

Input

Input is given from Standard Input in the following format:


N


Output

Print N numbers a_1, a_2, a_3, ..., a_N in a line, with spaces in between.

Examples

Input

5


Output

3 5 7 11 31


Input

6


Output

2 3 5 7 11 13


Input

8


Output

2 5 7 13 19 37 67 79

Source: atcoder | Difficulty: UNKNOWN_DIFFICULTY


Solutions:
print(*[11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381, 1451, 1471, 1481, 1511, 1531][:int(input())], sep=' ')


k = int(input())
n = 55555
primes = set(range(2, n + 1))
for i in range(2, int(n ** 0.5 + 1)):
	primes.difference_update(range(i * 2, n + 1, i))
primes = list(primes)
p1 = [i for i in primes if i % 5 == 1]
print(*p1[:k])


import math
N = int(input())
P = []
for k in range(2, 55555):
	f = 1
	for l in range(2, int(math.sqrt(k)) + 1):
		if k % l == 0:
			f = 0
	if f and k % 5 == 1:
		P.append(k)
	if len(P) >= N:
		break
print(' '.join(map(str, P)))


from math import floor
n = int(input())
ans_list = []
ans_num = 0
ans = 1
while ans_num < n:
	ans += 5
	for i in range(2, floor(ans ** 0.5) + 1):
		if ans % i == 0:
			break
	else:
		ans_list.append(ans)
		ans_num += 1
print(*ans_list)


n = int(input())
ans = []

def sosu(x):
	for i in range(2, x):
		if x % i == 0:
			return False
	return True
for i in range(11, 55555, 5):
	if sosu(i) and i % 5 == 1:
		ans.append(i)
		if len(ans) >= n:
			break
print(' '.join([str(s) for s in ans]))


INF = 55555
P = [1 for _ in range(55556)]
P[0] = 0
P[1] = 0
for i in range(2, int(55556 ** 0.5) + 1):
	for j in range(i * i, 55556, i):
		P[j] = 0
N = int(input())
A = []
for i in range(11, 55556, 10):
	if P[i] == 1:
		A.append(i)
	if len(A) == N:
		break
print(*A)


N = int(input())
ans = []
for p in range(7, 55555, 10):
	(pr, j) = (True, 3)
	while j * j <= p:
		if p % j == 0:
			pr = False
			break
		j += 2
	if pr:
		ans.append(p)
		if len(ans) == N:
			break
print(*ans)


n = int(input())
prim = [1] * 55556
prim[0] = 0
prim[1] = 0
for i in range(2, 55556):
	for j in range(2, 55556 // i):
		prim[i * j] = 0
ans = [2]
for i in range(55556):
	if prim[i] and i % 5 == 1:
		ans.append(i)
print(*ans[:n])


n = int(input())
(P, A) = ([2], [2])
for i in range(3, 55556, 2):
	for p in P:
		if i % p == 0:
			break
	else:
		P.append(i)
		if i % 5 == 2:
			A.append(i)
	if len(A) == n:
		break
print(*A)


L = [[] for i in range(5)]
for i in range(2, 55556):
	D = 0
	for j in range(2, int(i ** (1 / 2)) + 1):
		if i % j == 0:
			D = -1
			break
	if D == 0:
		L[i % 5].append(i)
N = int(input())
print(' '.join(map(str, L[1][:N])))


n = int(input())
prime = [1] * 55556
prime_num = []
for i in range(2, 55556):
	if prime[i] and i % 5 == 1:
		prime_num.append(i)
	t = 1
	while t * i <= 55555:
		prime[t * i] = 0
		t += 1
print(*prime_num[:n])


def isPrime(n):
	for i in range(2, int(n ** (1 / 2)) + 2):
		if n % i == 0:
			return False
	return True
N = int(input())
l = []
for i in range(2, 55556):
	if len(l) >= N:
		break
	if isPrime(i) and i % 5 == 1:
		l.append(i)
print(*l)


from math import *
M = 55555
tab = [True] * (M + 1)
for i in range(2, int(sqrt(M))):
	j = 2
	while i * j <= M:
		tab[i * j] = False
		j += 1
N = int(input())
ans = []
for i in range(2, M + 1):
	if tab[i] and i % 5 == 1:
		ans.append(str(i))
		if len(ans) >= N:
			break
print(' '.join(ans))


p = {2, 3}
(n, c, k) = (5, 0, int(input()))
while c < k:
	for j in p:
		if n % j == 0:
			n += 1
			break
	else:
		p.add(n)
		if n % 5 == 1:
			print(n, end=' ')
			c += 1
print()


def is_prime(n):
	i = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += 1
	return True
N = int(input())
primes = []
for i in range(2, 55556):
	if is_prime(i) == True:
		if i % 5 == 1:
			primes.append(i)
	if len(primes) == N:
		break
print(*primes)


N = int(input())
import math
prime = []
for n in range(2, 55556):
	for i in range(2, math.floor(math.sqrt(n)) + 1):
		if n % i == 0:
			break
	else:
		if n % 5 == 1:
			prime.append(n)
print(' '.join(list(map(str, prime[:N]))))


primes = [2]
for p in range(3, 55556, 2):
	isPrime = True
	for q in primes:
		if q * q > p:
			break
		if p % q == 0:
			isPrime = False
			break
	if isPrime:
		primes.append(p)
primes_1 = [p for p in primes if p % 5 == 1]
print(*primes_1[:int(input())])


mx = 100000
p = [True] * (mx + 10)
p[0] = p[1] = False
for i in range(2, mx + 1):
	if p[i] == True:
		for j in range(i * i, mx + 1, i):
			p[j] = False
A = []
for i in range(1, mx + 1):
	if p[i] == True and i % 5 == 1:
		A.append(i)
N = int(input())
print(*A[0:N])


n = int(input())

def prime_check(x):
	for i in range(2, x):
		if x % i == 0:
			return False
	return True
ans = []
for i in range(11, 55555, 10):
	if prime_check(i):
		ans.append(i)
		n -= 1
	if n == 0:
		break
print(*ans)


n = int(input())
MX = 55555
is_prime = [True] * MX
is_prime[0] = False
is_prime[1] = False
for i in range(2, MX):
	if not is_prime[i]:
		continue
	for j in range(2 * i, MX, i):
		is_prime[j] = False
ans = [i for (i, j) in enumerate(is_prime) if j and i % 5 == 1]
print(*ans[:n])


n = int(input())
fact = [True] * 55556
fact[0] = False
fact[1] = False
ans = []
for i in range(2, len(fact)):
	if fact[i]:
		if i % 5 == 1:
			ans += [i]
			if len(ans) == n:
				print(*ans)
				break
		for j in range(i * 2, len(fact), i):
			fact[j] = False


data = []
now = 1
while len(data) < 55:
	now += 10
	t = True
	for i in range(2, now - 1):
		if now % i == 0:
			t = False
			break
	if t:
		data.append(now)
n = int(input())
print(*data[:n])


n = int(input())
lst = []
for i in range(2, 55555):
	for j in range(2, int(i ** (1 / 2)) + 1):
		if i % j == 0:
			break
	else:
		lst.append(i)
li = []
count = 0
for u in lst:
	if u % 5 == 2:
		li.append(u)
		count += 1
		if count == n:
			break
print(*li)


n = int(input())
a = [2]
b = [2]
for i in range(3, 10000000):
	t = 0
	while t < len(a):
		if i % a[t] == 0:
			break
		else:
			t += 1
	else:
		a.append(i)
		if i % 5 == 2:
			b.append(i)
	if len(b) == 55:
		break
b.sort()
print(' '.join(list(map(str, b[:n]))))


(n, P, A) = (int(input()), [2], [])
for L in range(3, 9999):
	if len(A) == n:
		break
	if all((L % M for M in P)):
		P += (L,)
		if L % 5 == 1:
			A += (L,)
print(*A)


def prime_table(N):
	P = [False] * 2 + [True] * (N - 1)
	for i in range(2, int(N ** 0.5) + 1):
		if P[i]:
			P[2 * i::i] = [False] * (N // i - 1)
	return P
N = int(input())
print(*[i for (i, p) in enumerate(prime_table(55555)) if p and i % 10 == 1][:N])


n = int(input())

def prime(INF=10 ** 6 + 1):
	p = [1] * INF
	for i in range(2, INF):
		if p[i]:
			for j in range(2 * i, INF, i):
				p[j] = 0
	(p[0], p[1]) = (0, 0)
	return p
p = prime()
a = []
cnt = 0
for i in range(10 ** 6 + 1):
	if p[i] and i % 5 == 1:
		a += [i]
		cnt += 1
	if cnt == n:
		break
print(*a)


p = [True] * 100010
p[0] = p[1] = False
for i in range(2, 100000):
	if p[i] == True:
		for j in range(2 * i, 100000, i):
			p[j] = False
n = int(input())
a = []
i = 6
while len(a) < n:
	if p[i]:
		a.append(i)
	i += 5
for i in a:
	print(i, end=' ')


n = int(input())
l = [0] * 55556
i = 2
while i <= 55555:
	j = 2
	while i * j <= 55555:
		l[i * j] = 1
		j += 1
	i += 1
ans = []
for i in range(3, 55556):
	if l[i]:
		continue
	if (i - 1) // 2 % 5 == 0:
		ans.append(i)
print(*ans[:n])


prime = list(range(3, 2000, 2))
for p in prime:
	prime = [pp for pp in prime if (pp % p != 0) | (pp == p)]
n = int(input())
ans = 0
ans_list = []
for p in prime:
	if p % 5 == 1:
		ans += 1
		ans_list.append(p)
	if ans == n:
		break
print(*ans_list)


n = int(input())
pri = [1] * 10 ** 7
ans = []
for i in range(2, 55556):
	if pri[i] > 0:
		if i % 5 == 1:
			ans.append(i)
		for k in range(1, 55556 // i + 1):
			pri[i * k] = 0
print(' '.join(map(str, ans[:n])))


import math
n = int(input())

def chk(n):
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True
ans = []
for i in range(2, 10000 * 1000 + 1):
	if chk(i) and i % 5 == 1:
		ans.append(i)
	if len(ans) >= n:
		break
print(' '.join(map(str, ans)))


N = int(input())
P = [i * 2 + 3 for i in range(700)]
ans = []
for i in P:
	n = 2
	while i * n <= 1400:
		if i * n in P:
			P.remove(i * n)
		n += 1
for j in P:
	if j % 5 == 2:
		ans.append(j)
print(*ans[:N])


import math
N = int(input())

def is_prime(p):
	if p == 1:
		return false
	for i in range(2, int(math.sqrt(p)) + 1):
		if p % i == 0:
			return False
	return True
c = 0
for i in range(6, 55556, 5):
	if is_prime(i):
		c += 1
		if c != N:
			print(i, end=' ')
		else:
			print(i)
			exit()


n = int(input())

def is_prime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True
num = 11
tmp = 0
while 1:
	if is_prime(num):
		print(num, end=' ')
		tmp += 1
	num += 10
	if n == tmp:
		exit()


def simple_is_prime(n):
	if n == 1:
		return False
	for i in range(2, n):
		if n % i == 0:
			return False
	return True
N = int(input())
ans = []
for i in range(31, 55555, 30):
	if simple_is_prime(i):
		ans.append(i)
		N -= 1
	if N == 0:
		break
print(*ans)


a = [0] * 55556
N = int(input())
for i in range(2, 55556):
	for j in range(2 * i, 55556, i):
		a[j] += 1
A = []
for i in range(2, 55556):
	if a[i] == 0 and i % 5 == 1:
		A.append(str(i))
print(' '.join(A[:N]))


n = int(input())
prime = [2, 3]
ans = []
for i in range(4, 55556):
	for j in range(2, int(i ** 0.5) + 1):
		if i % j == 0:
			break
	else:
		prime.append(i)
for i in prime:
	if i % 5 == 1:
		ans.append(i)
print(*ans[:n])


N = int(input())

def get_prime_list(n):
	L = list(range(2, n + 1))
	for i in range(2, int((n + 1) ** 0.5)):
		if i not in L:
			continue
		L = [j for j in L if j <= i] + [j for j in L if j > i and j % i != 0]
	return L
L = [i for i in get_prime_list(55555) if i % 5 == 1]
print(*L[:N])


n = int(input())
maxp = 55555
primes = set(range(2, maxp + 1))
for i in range(2, int(maxp ** 0.5 + 1)):
	primes.difference_update(range(i * 2, maxp + 1, i))
primes = list(primes)
p5 = [i for i in primes if i % 5 == 1]
ans = p5[:n]
print(*ans)


n = int(input())
l = []
d = 1

def judge(p):
	for i in range(2, int(p ** 0.5 + 1)):
		if p % i == 0:
			return False
	return True
cnt = 0
while cnt < n:
	if judge(d * 10 + 1):
		l.append(d * 10 + 1)
		cnt += 1
	d += 1
print(*l)


N = int(input())
L = [str(i) for i in [11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381, 1451]]
print(' '.join(L[:N]))


N = int(input())
primes = [2, 3, 5, 7]
ans = []
for n in range(11, 55555 + 1):
	for p in primes:
		if n % p == 0:
			break
	else:
		primes.append(n)
		if n % 5 == 1:
			ans.append(n)
			if len(ans) >= N:
				break
print(' '.join(map(str, ans)))


N = int(input())

def prime(n):
	flag = False
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
			break
	return True
L = []
for i in range(2, 55556):
	if prime(i) and i % 5 == 1:
		L.append(i)
		if len(L) == N:
			break
print(*L[:N])


print(*[2, 7, 17, 37, 47, 67, 97, 107, 127, 137, 157, 167, 197, 227, 257, 277, 307, 317, 337, 347, 367, 397, 457, 467, 487, 547, 557, 577, 587, 607, 617, 647, 677, 727, 757, 787, 797, 827, 857, 877, 887, 907, 937, 947, 967, 977, 997, 1087, 1097, 1117, 1187, 1217, 1237, 1277, 1297][:int(input())])


import math

def is_prime(n):
	if n == 1:
		return False
	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False
	return True
x = [i for i in range(2, 55556) if is_prime(i) and i % 5 == 1]
print(*x[:int(input())])


n = int(input())
m = 10 ** 4
isp = [1] * m
isp[0] = isp[1] = 0
for i in range(2, int(m ** 0.5) + 1):
	if isp[i]:
		for j in range(i * i, m, i):
			isp[j] = 0
P = [i for (i, j) in enumerate(isp) if j > 0 and i % 5 == 1]
print(*P[:n])


def isPrime(n):
	i = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += 1
	return True
l = []
i = 2
while i < 55556:
	if isPrime(i) and i % 5 == 1:
		l.append(i)
	i += 1
N = int(input())
print(*l[:N])


from math import factorial
k = int(input())
n = 10000
primes = [2]
for i in range(3, n, 2):
	all((i % p != 0 for p in primes)) and primes.append(i)
primes = [i for i in primes if i % 5 == 1][:k]
print(*primes)


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

def main():
	N = int(input())
	PRIMES = [i * 10 + 1 for i in range(2, 146) if isprime(i * 10 + 1)]
	print(' '.join(map(str, PRIMES[:N])))
main()


import math

def prime(a):
	for i in range(2, int(math.sqrt(a)) + 1):
		if a % i == 0:
			return False
	else:
		return True
m = 5555
xs = []
for i in range(1, m):
	if prime(i * 10 + 1):
		xs.append(i * 10 + 1)
		if len(xs) > 55:
			break
n = int(input())
print(*xs[:n])


def isprime(i):
	j = 2
	while j ** 2 <= i:
		if i % j == 0:
			return False
		j += 1
	return True
n = int(input())
x = []
for i in range(6, 55552, 5):
	if isprime(i):
		x.append(i)
	if len(x) == n:
		break
print(*x)


N = int(input())
A = []
for i in range(2, 55556):
	if i % 5 == 1:
		j = 2
		while j < i:
			if i % j == 0:
				break
			j += 1
		if i - j == 0:
			A.append(i)
	if len(A) >= N:
		break
print(*A[:N])


N = int(input())
prime = []
for i in range(11, 1500, 10):
	for j in range(2, int(i ** 0.5) + 1):
		if i % j == 0:
			break
	else:
		prime.append(i)
print(*prime[:N])


n = int(input())
d = []
for i in range(1, 11111 + 1):
	m = 5 * i - 1
	if m % 2 == 0:
		continue
	f = 3
	while f * f < m + 1:
		if m % f == 0 or len(d) == n:
			break
		f += 2
	else:
		d.append(m)
print(*d)


import sys
input = sys.stdin.readline

def is_prime(x):
	if x == 1:
		return False
	for i in range(2, int(x ** 0.5) + 1):
		if x % i == 0:
			return False
	return True
N = int(input())
ans = []
i = 2
while len(ans) < N:
	a = i * 5 + 1
	if is_prime(a):
		ans.append(a)
	i += 1
print(*ans)


import math
N = int(input())

def isPrime(n):
	if n == 2 or n == 3:
		return True
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True
primes = [str(i) for i in range(2, 55555 + 1) if i % 5 == 1 and isPrime(i)]
print(' '.join(primes[0:N]))


n = int(input())
X = []

def j(n):
	if n % 2 == 0:
		return False
	for i in range(3, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			return False
	return True
for i in range(2, 55556):
	if j(i) and i % 5 == 1:
		X.append(i)
print(*X[:n])


def gen_primes(N):
	from itertools import compress
	sieve = list(range(N))
	sieve[1] = 0
	for i in range(2, int(N ** 0.5) + 1):
		sieve[i * 2::i] = [0] * len(sieve[i * 2::i])
	return list(compress(range(N), sieve))
N = int(input())
print(*[p for p in gen_primes(55555) if p % 5 == 1][:N])


N = int(input())
sosu = [2, 3, 5, 7]
A = []
M = 11
while len(A) < N:
	if all((M % i != 0 for i in sosu)):
		sosu.append(M)
		if M % 5 == 1:
			A.append(M)
	M += 2
print(*A)


N = int(input())
import math

def isprime(x):
	for i in range(2, math.floor(math.sqrt(x)) + 2):
		if x % i == 0:
			return False
			break
	return True
L = []
one = 11
while len(L) < N:
	if isprime(one):
		L.append(one)
	one += 10
print(*L)


N = int(input())
fact = [True] * 55556
(fact[0], fact[1]) = (False, False)
ans = []
cnt = 0
for i in range(2, len(fact)):
	if fact[i]:
		if i % 5 == 1:
			ans.append(i)
			cnt += 1
			if cnt == N:
				break
		for j in range(i * 2, len(fact), i):
			fact[j] = False
print(*ans)


def mark(s, x):
	for i in range(x + x, len(s), x):
		s[i] = False

def sieve2(n):
	s = [True] * n
	for x in range(2, int(n ** 0.5) + 1):
		if s[x]:
			mark(s, x)
	return [i for i in range(0, n) if s[i] and i % 5 == 2]
print(' '.join(map(str, sieve2(55555)[:int(input())])))


n = int(input())
primes = []
for i in range(11, 1500, 10):
	isPrime = True
	for k in range(2, 236):
		if k ** 2 > i:
			break
		elif i % k == 0:
			isPrime = False
			break
	if isPrime:
		primes.append(i)
print(' '.join(map(str, primes[:n])))


N = int(input())
ans = list()
flag = [0] * 55556
flag[1] = 1
for i in range(1, 55556):
	if flag[i] == 0:
		if i % 5 == 1:
			ans.append(i)
		p = i
		while p <= 55555:
			flag[p] = 1
			p += i
print(*ans[:N])


N = int(input())
cur = 1
ans = []
while N > 0:
	to_test = int(str(cur) + '1')
	for j in range(2, int(to_test ** 0.5) + 1):
		if to_test % j == 0:
			break
	else:
		ans.append(str(to_test))
		N -= 1
	cur += 1
print(' '.join(ans))


n = int(input())
l = [11, 31, 41, 61, 71]
if n == 5:
	print(*l)
	exit()
for i in range(81, 60000, 10):
	check = True
	for j in range(3, int(i ** 0.5) + 1):
		if i % j == 0:
			check = False
	if check:
		l.append(i)
	if len(l) == n:
		print(*l)
		exit()


N = int(input())
MAXA = 55555
P = []
X = [True] * (MAXA + 1)
X[0] = X[1] = False
for i in range(MAXA + 1):
	if X[i]:
		P.append(i)
		X[i::i] = [False] * (MAXA // i)
X = []
for p in P:
	if p % 5 == 1:
		X.append(p)
print(*X[:N])


N = int(input())
ans = []
x = 6
while len(ans) < N:
	for y in range(2, int(x ** 0.5) + 1):
		if x % y == 0:
			break
	else:
		ans.append(x)
	x += 5
print(*ans)


N = int(input())
nums = [[i, True] for i in range(55555 + 1)]
for i in range(2, 55555 + 1):
	if nums[i][1]:
		if nums[i][0] % 5 == 1:
			print(nums[i][0])
			N -= 1
		for j in range(i, 55555 + 1, nums[i][0]):
			nums[j][1] = False
	if not N:
		break


def prm(x):
	if x == 1:
		return False
	for i in range(2, x):
		if x % i == 0:
			return False
	else:
		return True
n = int(input())
ans = []
for j in range(1, 55551, 5):
	if prm(j):
		ans.append(j)
		if len(ans) == n:
			break
print(*ans, sep=' ')


Modoneprime = []
import math
for i in range(1, 11110):
	count = 0
	k = 5 * i + 1
	for j in range(2, math.floor(math.sqrt(k)) + 1):
		if k % j == 0:
			count += 1
	if count > 0:
		continue
	else:
		Modoneprime.append(k)
N = int(input())
print(*Modoneprime[0:N])


def main():
	N = int(input())
	ps = [2]
	ans = ['2']
	i = 3
	while len(ans) < N:
		is_prime = True
		for p in ps:
			if i % p == 0:
				is_prime = False
				break
		if is_prime:
			ps.append(i)
			if i % 5 == 2:
				ans.append(str(i))
		i += 1
	print(' '.join(ans))
main()


from math import sqrt
lst = []

def prime(x, lst):
	n = int(sqrt(x))
	for i in range(2, n + 1):
		if x % i == 0:
			return lst
	if x % 5 == 1:
		lst.append(x)
for i in range(2, 55555):
	prime(i, lst)
m = int(input())
y = ''
for i in range(m):
	y += str(lst[i]) + ' '
print(y)


n = int(input())
num = list(range(2, 2000))[::-1]
pri = []
while num:
	p = num.pop()
	pri.append(p)
	num = [i for i in num if i % p]
five = [i for i in pri if i % 5 == 1]
ans = five[:n]
print(' '.join(map(str, ans)))


n = int(input())

def prime(n):
	i = 2
	while i < n:
		if n % i == 0:
			return False
		else:
			i += 1
	return True
nums = []
k = 11
while len(nums) <= n:
	if prime(k) == True:
		nums.append(k)
	k += 10
ans = str(nums[0])
i = 1
while i < n:
	ans = ans + ' ' + str(nums[i])
	i += 1
print(ans)


n = int(input())
l = []

def prime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	else:
		return True
for i in range(2, 55556):
	if prime(i) and i % 5 == 1:
		l.append(i)
for i in range(n):
	print(l[i], end=' ')


n = int(input())
ans = []

def is_prime(x):
	for y in range(3, int(x ** (1 / 2)) + 2, 2):
		if x % y == 0:
			return False
	return True
cur = 11
while len(ans) < n:
	if is_prime(cur):
		ans.append(cur)
	cur += 10
print(' '.join(map(str, ans)))


N = int(input())
hurui = [True] * 55556
for i in range(2, int(55555 ** 0.5) + 1):
	for j in range(i * 2, 55556, i):
		hurui[j] = False
sosu = []
for i in range(2, 55556):
	if i % 5 != 1:
		continue
	if hurui[i]:
		sosu.append(i)
print(*sosu[:N])


n = int(input())
res = []
num = 6
while len(res) < n:
	num += 5
	if all((num % i != 0 for i in range(2, int(num ** 0.5) + 1))):
		res.append(num)
print(*res)


def isPrime(x):
	for i in range(2, min(x, 236)):
		if x % i == 0:
			return False
	return True
(n, a, p) = (int(input()), [], 2)
while n > 0:
	if isPrime(p):
		a.append(str(p))
		n -= 1
	p += 5
print(' '.join(a))


import math
P = [2]
for k in range(3, 1400):
	f = 1
	for l in range(2, int(math.sqrt(k)) + 1):
		if k % l == 0:
			f = 0
			break
	if f == 1:
		P.append(k)
Q = []
for p in P:
	if p % 5 == 1:
		Q.append(p)
print(' '.join(map(str, Q[:int(input())])))


N = int(input())
Z = [2, 3, 5, 7, 11, 13, 17]
for i in range(2, 1500):
	flag = 0
	for j in Z[:]:
		if i % j == 0:
			flag = 1
			break
	if flag == 1:
		continue
	else:
		Z.append(i)
Z = [i for i in Z if i % 10 == 1]
print(' '.join(map(str, Z[:N])))


N = int(input())
p = []

def check(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True
for i in range(2, 55556):
	for j in range(2, int(i ** 0.5) + 1):
		if i % j == 0:
			break
	else:
		if i % 5 == 1:
			p += [i]
ans = p[:N]
print(*ans)


n = int(input())
pn = [2]
A = 2000
for L in range(3, A):
	chk = True
	for L2 in pn:
		if L % L2 == 0:
			chk = False
	if chk == True:
		pn.append(L)
l = []
for i in pn:
	if i % 5 == 1:
		l.append(i)
print(*l[:n])


from itertools import *
n = range(55555)
a = list(n)
a[1] = 0
for i in range(2, 233):
	a[i * 2::i] = [0] * len(a[i * 2::i])
p = list(compress(n, a))
cnt = 0
ans = []
N = int(input())
for x in p:
	if x % 5 == 2:
		ans += [x]
		cnt += 1
		if cnt == N:
			break
print(*ans)


N = int(input())
prime = [False] * 2 + [True] * 55554
for i in range(2, 55556):
	if prime[i]:
		prime[2 * i::i] = [False] * (55555 // i - 1)
arr = []
for i in range(11, 55556):
	if prime[i] and i % 10 == 1:
		arr.append(str(i))
print(' '.join(arr[:N]))


from math import sqrt

def is_prime(n):
	u = int(sqrt(n) + 1)
	for i in range(2, u):
		if n % i == 0:
			return 0
	return 1
num = int(input())
a = 11
b = 0
while b < num:
	if is_prime(a):
		print(a, end=' ')
		b += 1
	a += 10


n = int(input())
a = []
for i in range(11, 55556):
	if i % 5 == 1 and i % 2 == 1:
		f = 0
		for j in range(2, round(i ** 0.5) + 1):
			if i % j == 0:
				f = 1
				break
		if f == 0:
			a.append(i)
print(*a[:n])


n = int(input())
a = 11
p = [11]

def is_prime(x):
	if x % 2 == 0:
		return False
	for i in range(3, x // 2 + 1, 2):
		if x % i == 0:
			return False
	else:
		return True
while len(p) < n:
	a += 5
	if is_prime(a):
		p.append(a)
print(*p)


n = int(input())
P = []
for i in range(11, 55556, 10):
	p = 1
	for j in range(2, int(i ** 0.5) + 1):
		if i % j == 0:
			p = 0
	if p == 1:
		P.append(i)
s = ''
for i in range(n - 1):
	s += str(P[i]) + ' '
s += str(P[n - 1])
print(s)


n = int(input())

def is_prime(num):
	i = 2
	while i ** 2 <= num:
		if num % i == 0:
			return False
		i += 1
	return True
candi = []
for i in range(2, 55556):
	if is_prime(i) and i % 5 == 1:
		candi.append(i)
print(*candi[:n])


import sys
N = int(sys.stdin.readline().rstrip())
ANS = [2, 11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361]
print(*ANS[:N])


N = int(input())
lst = [0] * 55556
prime = []
for i in range(2, 55556):
	if lst[i] == 0:
		if i % 10 == 1:
			prime.append(i)
		for j in range(i, 55556, i):
			lst[j] = 1
	if len(prime) == N:
		print(*prime)
		exit()


N = int(input())
x = [0] * (55555 + 10)
ans = []
for i in range(2, 55556):
	if x[i] == 0:
		t = i
		while t < 55556:
			x[t] = 1
			t += i
		if i % 5 == 1:
			ans.append(i)
			if len(ans) == N:
				break
print(*ans)


N = int(input())
prime = []
for i in range(1, 150):
	n = 1 + 10 * i
	for j in range(2, n + 1):
		if n % j == 0:
			if n == j:
				prime.append(str(n))
			else:
				break
print(' '.join(prime[0:N]))


import math

def isprime(n):
	if n == 1:
		return False
	if n == 2:
		return True
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True
n = int(input())
l = []
tmp = 11
while len(l) < n:
	if isprime(tmp):
		l.append(tmp)
	tmp += 10
print(*l)


n = int(input())
l = []

def prime(N):
	for i in range(2, int(N ** 0.5) + 1):
		if N % i == 0:
			return False
			break
	return True
for i in range(2, 55555):
	if prime(i) is True and i % 5 == 1:
		l.append(i)
	if len(l) >= n:
		break
print(' '.join(map(str, l)))


def isprime(num):
	for k in range(2, int(num ** 0.5) + 1):
		if num % k == 0:
			return False
	return True
n = int(input())
pl = []
for i in range(2, 55555):
	if i % 5 == 1:
		if isprime(i):
			pl.append(i)
print(' '.join(list(map(str, pl[0:n]))))


n = int(input())

def is_prime(n):
	i = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += 1
	return n != 1
l = list()
for i in range(6, 55555, 5):
	if is_prime(i):
		l.append(i)
		n -= 1
	if n == 0:
		print(*l)
		exit()


N = int(input())
pns = [2]
for i in range(3, 1500):
	for pn in pns:
		if i % pn == 0:
			break
	else:
		pns.append(i)
print(' '.join([str(pn) for pn in pns if pn % 10 == 1][:N]))


import math

def is_prime(n):
	if n == 1:
		return False
	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False
	return True
a = []
for i in range(55555):
	if i % 5 == 1:
		if is_prime(i):
			a.append(i)
N = int(input())
for i in range(N):
	print(a[i], end=' ')


N = int(input())
sosuu = []
ans = []
for i in range(2, 55556):
	flag = True
	for s in sosuu:
		if i ** 0.5 < s:
			break
		if i % s == 0:
			flag = False
			break
	if flag:
		sosuu.append(i)
		if i % 5 == 1:
			ans.append(i)
print(' '.join(map(str, ans[:N])))


n = int(input())
prime_5 = []
for i in range(2, 55556):
	flg = i % 5 == 1
	if flg:
		for j in range(2, int(i ** 0.5) + 1):
			if i % j == 0:
				flg = False
				break
	if flg:
		prime_5.append(i)
print(*prime_5[:n])


n = int(input())
mx = 55555
ans = []
primes = [2]
for i in range(3, mx + 1, 2):
	if all((i % p != 0 for p in primes)):
		primes.append(i)
		if i % 5 == 1:
			ans.append(i)
		if len(ans) == n:
			break
print(*ans)


N = int(input())
P = []
for i in range(1, 11111):
	p = 5 * i + 1
	hantei = True
	for j in range(2, int(p ** 0.5) + 1):
		if p % j == 0:
			hantei = False
	if hantei:
		P += [p]
print(*P[:N])


N = int(input())

def isprime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True
A = []
cnt = 0
c = 6
while True:
	if isprime(c):
		A.append(c)
		cnt += 1
	if cnt >= N:
		break
	c += 5
print(*A)


N = int(input())
L = [0, 0] + [1] * 55555
K = []
for i in range(len(L)):
	if L[i]:
		for j in range(2 * i, len(L), i):
			L[j] = 0
		if i % 5 == 1:
			K.append(i)
			if len(K) == N:
				break
print(*K)


N = int(input())
ans = []
n = 55555
primes = set(range(2, n + 1))
for i in range(2, int(n ** 0.5 + 1)):
	primes.difference_update(range(i * 2, n + 1, i))
primes = list(primes)
for i in primes:
	if i % 5 == 1:
		ans.append(i)
print(*ans[:N])


N = int(input())
primes = set([2])
mod5_1 = []
for i in range(3, 55555 + 1):
	if len(mod5_1) == N:
		break
	for p in primes:
		if i % p == 0:
			break
	else:
		primes.add(i)
		if i % 5 == 1:
			mod5_1.append(i)
print(*mod5_1)


n = int(input())
p = [3, 13, 23, 43, 53, 73, 103, 113, 163, 173, 193, 223, 233, 263, 283, 293, 313, 353, 373, 383, 443, 463, 503, 563, 593, 613, 643, 653, 673, 683, 733, 743, 773, 823, 853, 863, 883, 953, 983, 1013, 1033, 1063, 1093, 1103, 1123, 1153, 1163, 1193, 1213, 1223, 1283, 1303, 1373, 1423, 1433, 1453, 1483, 1493]
for i in range(n):
	print(p[i], end=' ')


n = int(input())
i = j = 0
a = []

def p(n):
	if n == 1:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True
while i < n:
	if p(5 * j + 1):
		i += 1
		a.append(5 * j + 1)
	j += 1
print(*a)


a = [2]
b = [2]
for i in range(3, 100000):
	t = 0
	while t < len(a):
		if i % a[t] == 0:
			break
		else:
			t += 1
	else:
		a.append(i)
		if i % 5 == 2:
			b.append(i)
	if len(b) == 55:
		break
b.sort()
print(*b[:int(input())])


n = int(input())
listA = [29, 59, 89, 149, 179]
i = 7
while len(listA) < n:
	for j in range(7, (30 * i - 1) // 2 + 1):
		if (30 * i - 1) % j == 0:
			break
		elif j == (30 * i - 1) // 2:
			listA.append(30 * i - 1)
	i += 1
print(' '.join(map(str, listA)))


N = int(input())
lineup = [7, 17, 37, 47, 107, 127, 137, 157, 167, 197, 227, 257, 277, 307, 317, 337, 347, 367, 397, 467, 487, 557, 577, 587, 607, 617, 677, 727, 757, 797, 827, 857, 877, 887, 907, 947, 967, 977, 997, 1087, 1097, 1117, 1187, 1217, 1237, 1277, 1297, 1307, 1327, 1367, 1427, 1447, 1487, 1567, 1597, 1607]
print(*lineup[:N])


import math
N = int(input())
l = [i for i in range(55556)]
l[1] = 0
for i in l[1:]:
	if i > math.sqrt(55556):
		break
	if i == 0:
		continue
	for j in range(2 * i, 55556, i):
		l[j] = 0
prime = [i for i in l if l != 0 and (i - 3) % 10 == 0]
print(' '.join(map(str, prime[:N])))


n = int(input())
primes = []
for i in range(11, 1500, 10):
	for j in range(2, int(i ** 0.5) + 1):
		if i % j == 0:
			break
	else:
		primes.append(i)
print(*primes[:n])


era = [1] * 55556
era[0] = era[1] = 0
for i in range(2, int(55556 ** 0.5) + 1):
	if era[i] == 1:
		for j in range(i * 2, 55556, i):
			era[j] = 0
v = [0] * 5
n = int(input())
for i in range(55556):
	if era[i] and i % 5 == 1:
		print(i, end=' ')
		n -= 1
		if n == 0:
			break
print()


n = int(input())
ps = []

def isPrime(target):
	for i in range(2, target):
		if target % i == 0:
			return False
	return True
for i in range(11, 55555, 5):
	if isPrime(i):
		ps.append(i)
		if len(ps) == n:
			break
print(*ps)


n = int(input())
i = 11
cnt = 0
ans = []
while cnt < n:
	for j in range(2, int(i ** 0.5) + 1):
		if i % j == 0:
			i += 10
			break
	else:
		cnt += 1
		ans.append(i)
		i += 10
print(' '.join(list(map(str, ans))))


x = int(input())
a = [0] * x
k = 0
t = 0
for i in range(11, 55555, 10):
	t = 0
	for j in range(2, round(i ** 0.5) + 2):
		if i % j == 0:
			t = 1
	if t == 0 and k < x:
		a[k] = i
		k = k + 1
print(*a)


p = []
for i in range(1, 11111 + 1):
	flag = True
	N = i * 5 + 1
	for j in range(2, int(N ** 0.5) + 1):
		if N % j == 0:
			flag = False
			break
	if flag:
		p.append(N)
N = int(input())
for i in range(N):
	print(p[i], end=' ')


n = int(input())
p = [1] * 55556
i = 2
while n:
	if p[i]:
		for j in range(i + i, 55556, i):
			p[j] = 0
		if i % 10 == 1:
			print(i, end=' ')
			n -= 1
	i += 1


nim = int(input())
array = [0] * 55556
prime = []
for i in range(2, 55556):
	if array[i] == 0:
		if i % 10 == 1:
			prime.append(i)
		for j in range(i, 55556, i):
			array[j] = 1
	if len(prime) == nim:
		print(*prime)
		exit()


def is_prime(n):
	if n == 1:
		return False
	for k in range(2, int(n ** 0.5) + 1):
		if n % k == 0:
			return False
	return True
n = int(input())
c = 1
d = 11
L = [2]
while c < n:
	if is_prime(d):
		L.append(d)
		c += 1
	d += 10
print(*L, sep=' ')


n = int(input())
p = []
a = []
q = 2
while len(a) < n:
	f = 0
	for x in p:
		if q % x == 0:
			f = 1
			break
	if f == 0:
		p += [q]
		if q % 5 == 1:
			a += [str(q)]
	q += 1
print(' '.join(a))


n = int(input())
lst = []
d = [False for I in range(55556)]
for i in range(2, 55555):
	if d[i] == False:
		lst.append(i)
		for j in range(i, 55555, i):
			d[j] = True
ans = []
for i in lst:
	if i % 5 == 1:
		ans.append(i)
print(*ans[:n])


N = int(input())
ans = [2]
i = 7
flag = 0
while len(ans) < N:
	for j in range(2, int(i ** 0.5) + 1):
		if i % j == 0:
			flag = 1
			break
	if flag != 1:
		ans.append(i)
	i += 5
	flag = 0
for i in range(len(ans)):
	print(ans[i], end=' ')


N = int(input())
List = [2]
Newlist = []
for i in range(3, 10 ** 4):
	for j in List:
		if i % j == 0:
			break
	else:
		List.append(i)
for j in List:
	if j % 5 == 1:
		Newlist.append(j)
for j in range(N):
	print(Newlist[j], end=' ')


dp = [0] * 55556
dp[0] = 1
dp[1] = 1
prime = []
for i in range(55556):
	if dp[i] == 0:
		prime.append(i)
		for j in range(i, 55556, i):
			dp[j] = 1
Enable = []
for i in prime:
	if i % 5 == 1:
		Enable.append(i)
N = int(input())
for i in Enable[:N]:
	print(i, end=' ')


import math
N = int(input())

def isPrime(n):
	for k in range(2, int(math.sqrt(n)) + 2):
		if n % k == 0:
			return False
	else:
		return True
plist = [2]
p = 11
while len(plist) < N:
	if p % 5 == 1 and isPrime(p):
		plist.append(p)
	p += 10
print(' '.join(map(str, plist)))


N = int(input())

def isprime(p):
	if p == 1:
		return False
	for i in range(2, int(p ** 0.5 + 1)):
		if p % i == 0:
			return False
	return True
ans = []
for i in range(11, 55556, 10):
	if isprime(i):
		ans.append(i)
		N -= 1
	if N == 0:
		break
print(*ans)


n = int(input())
prime5 = []
for i in range(1, 5600):
	a = i * 10 + 1
	for j in range(3, int(a ** 0.5) + 1):
		if a % j == 0:
			break
	else:
		prime5.append(a)
print(*prime5[:n])


from math import sqrt, floor
N = int(input())
L = []
for i in range(2, 55556):
	if i % 10 != 1:
		continue
	flag = True
	for j in range(2, int(sqrt(i)) + 4):
		if i % j == 0:
			flag = False
	if flag:
		L.append(i)
print(' '.join(map(str, L[:N])))


def PRIME(N):
	LIM = int(N ** 0.5) + 2
	for i in range(2, LIM):
		if N % i == 0:
			return False
	return True
n = int(input())
p = []
ans = ''
for i in range(2, 55556):
	if i % 5 == 1:
		if PRIME(i):
			p.append(i)
for j in range(n):
	ans += str(p[j]) + ' '
print(ans)


n = int(input())
work = [True] * 55556
work[0] = False
work[1] = False
primes = []
for i in range(55556):
	if work[i]:
		for j in range(2 * i, 55556, i):
			work[j] = False
ret = [2]
i = 6
while len(ret) != n:
	i += 5
	if work[i]:
		ret.append(i)
print(' '.join(map(str, ret)))


MAX = 55555
p = [1] * (MAX + 1)
(p[0], p[1]) = (0, 0)
pp = []
for i in range(2, MAX, 2):
	p[i] = 0
for i in range(3, int(MAX ** 0.5) + 1, 2):
	if p[i]:
		for j in range(i * 2, MAX, i):
			p[j] = 0
for i in range(MAX + 1):
	if p[i] and i % 5 == 1:
		pp.append(i)
n = int(input())
print(' '.join(map(str, pp[:n])))


def is_prime(n):
	if n == 1:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True
p = []
for i in range(1, 11111):
	n = 5 * i + 1
	if is_prime(n):
		p.append(str(n))
N = int(input())
ans = p[:N]
print(' '.join(ans))


N = int(input())
ans = []
i = 1
while len(ans) < N:
	tmp = i * 10 + 1
	i += 1
	flag = 0
	for j in range(3, tmp // 3 + 1):
		if tmp % j == 0:
			flag = 1
			break
	if flag == 0:
		ans.append(tmp)
for i in ans:
	print(i, end=' ')


N = int(input())
dp = [True] * 55556
dp[0] = False
dp[1] = False
for i in range(2, 55556):
	if dp[i]:
		h = i + i
		while h < 55556:
			dp[h] = False
			h += i
ans = []
for i in range(55556):
	if dp[i] and i % 5 == 1:
		ans.append(i)
for a in ans[:N]:
	print(a, end=' ')


def is_prime(n):
	if n == 1:
		return False
	for k in range(2, int(n ** 0.5) + 1):
		if n % k == 0:
			return False
	return True
N = int(input())
ans = []
t = 11
while len(ans) < N:
	if is_prime(t):
		ans.append(t)
	t += 5
print(*ans)


N = int(input())
maxn = 55555
prime = [1] * (maxn + 1)
prime[0] = 0
prime[1] = 0
plst = []
for i in range(2, maxn + 1):
	if prime[i] == 1:
		if i % 5 == 1:
			plst.append(str(i))
		for j in range(2, maxn // i + 1):
			prime[i * j] = 0
print(' '.join(plst[:N]))


def check(x):
	for i in range(2, int(x ** 0.5) + 1):
		if x % i == 0:
			return False
	return True
n = int(input())
l = []
for i in range(11, 55551, 10):
	if check(i):
		l.append(i)
print(*l[:n])


N = int(input())
x = []
p = []
for i in range(2, 2000):
	if all((i % p_i for p_i in p)):
		p.append(i)
		if i % 5 == 1:
			x.append(i)
			if len(x) == N:
				break
print(*x)


n = int(input())
ans = []
isPrime = [True for i in range(55555 + 1)]
for i in range(2, 55555 + 1):
	if isPrime[i]:
		if str(i)[-1] == '3':
			ans.append(i)
			if len(ans) == n:
				break
		for j in range(2 * i, 55555 + 1, i):
			isPrime[j] = False
for i in ans:
	print(i)


N = int(input())
A = [True] * 100000
(A[0], A[1]) = (False, False)
for i in range(2, 100000):
	if A[i]:
		j = 2
		while i * j < 100000:
			A[i * j] = False
			j += 1
P = []
for i in range(100000):
	if A[i] and i % 5 == 1:
		P.append(i)
print(' '.join(map(str, P[:N])))


n = int(input())
a = [True] * 55556
b = []
a[0] = a[1] = False
p = 0
for i in range(2, 55556):
	if a[i]:
		b.append(i)
		for j in range(2 * i, 55556, i):
			a[j] = False
i = cnt = 0
ans = []
while cnt < n:
	if b[i] % 5 == 3:
		ans.append(b[i])
		cnt += 1
	i += 1
print(*ans)


import math
N = int(input())

def isPrime(n):
	for k in range(2, int(math.sqrt(n)) + 2):
		if n % k == 0:
			return False
	else:
		return True
plist = []
p = 1
while len(plist) < N:
	p += 10
	if isPrime(p):
		plist.append(p)
print(*plist)


N = int(input())
p = [True] * 55555
p[0] = False
p[1] = False
for i in range(2, int(55555 ** 0.5)):
	for j in range(i * 2, 55555, i):
		if j % i == 0:
			p[j] = False
p = [str(i) for (i, f) in enumerate(p) if f == True and i % 5 == 1][:N]
print(' '.join(p))


n = int(input())
k = 0
ans = []

def prime(p):
	j = 2
	while j * j <= p:
		if p % j == 0:
			return False
		j += 1
	return True
for i in range(6, 55556, 5):
	if k == n:
		break
	if prime(i):
		ans.append(i)
		k += 1
print(*ans)


def is_prime(n):
	if n % 2 == 0:
		return False
	for i in range(3, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			return False
	return True
print(*[i for i in range(6, 55556, 5) if is_prime(i)][:int(input())])


n = int(input())
result = [2]
i = 1
while len(result) < n:
	num = 5 * i - 1
	for j in range(2, int(pow(num, 0.5)) + 1):
		while num % j == 0:
			num //= j
	if num == 5 * i - 1:
		result.append(num)
	i += 1
print(*result)


n = int(input())
s = [2]
ans = []
t = 1
for i in range(3, 55556):
	flg = True
	for _ in s:
		if i % _ == 0:
			flg = False
	if flg:
		s.append(i)
		if i % 5 == 1:
			ans.append(str(i))
			t += 1
	if t > n:
		break
print(' '.join(ans))


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

def check(x):
	for i in range(2, int(sqrt(x)) + 2):
		if x % i == 0:
			return False
	return True
a = []
i = 0
while len(a) < n:
	i += 1
	if check(5 * i + 1):
		a.append(5 * i + 1)
print(*a, sep=' ')


Ps = []
M = [False] * 55556
for i in range(2, 55556):
	if not M[i]:
		Ps.append(i)
		for j in range(i, 55556, i):
			M[j] = True
Ps2 = list(filter(lambda p: p % 5 == 1, Ps))
N = int(input())
r = Ps2[:N]
print(' '.join(map(str, r)))


N = int(input())
ss = [2, 3, 5]
ans = []
for i in range(7, 55555):
	for j in ss:
		if i % j == 0:
			break
		if j > i ** 0.5:
			ss.append(i)
			if i % 5 == 1:
				ans.append(i)
			break
	if len(ans) == N:
		break
for i in range(N):
	print(ans[i], end=' ')


l = []
for i in range(6, 1382, 5):
	f = True
	for j in range(2, int(i ** 0.5) + 1):
		if i % j == 0:
			f = False
			break
	if f:
		l.append(i)
print(' '.join(map(str, l[:int(input())])))


n = int(input())
ps = list(range(55556))
ps[1] = 0
primes = []
for i in range(2, 55556 // 2):
	if ps[i] != 0:
		primes.append(i)
		for j in range(55556)[::i]:
			ps[j] = 0
primes = [p for p in primes if p % 5 == 1]
print(' '.join(map(str, primes[:n])))


N = int(input())
primes = [2]
res = []
for i in range(3, 55556):
	p = len(primes)
	f = 1
	for j in range(p):
		if i % primes[j] == 0:
			f = 0
	if f:
		primes.append(i)
		if i % 5 == 1:
			res.append(i)
	if len(res) == N:
		print(*res)
		break


n = int(input())
import math

def is_prime(n):
	if n == 1:
		return False
	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False
	return True
s = []
for i in range(1, 10 ** 6):
	if is_prime(i):
		if i % 5 == 1:
			s.append(i)
	if len(s) == n:
		break
print(*s)


n = int(input())

def isprime(p):
	if p < 2:
		return False
	for i in range(2, p):
		if p % i == 0:
			return False
	return True
sol = []
for i in range(3, 55555 + 1, 10):
	if isprime(i):
		sol.append(i)
	if len(sol) >= n:
		break
print(*sol)


N = int(input())

def is_prime(n):
	if n == 1:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True
p = []
for i in range(2, 55555 + 1):
	if is_prime(i) and i % 5 == 1:
		p.append(i)
print(*p[:N])


N = int(input())
n = 55555
prime = []
is_prime = [True] * (n + 1)
is_prime[0] = False
is_prime[1] = False
for i in range(2, n + 1):
	if is_prime[i]:
		if i % 5 == 1:
			prime.append(i)
		for j in range(2 * i, n + 1, i):
			is_prime[j] = False
print(*prime[:N])


N = int(input())
limitN = 60000
P = [0] * limitN
listP = []
for i in range(2, limitN):
	if P[i] == 0:
		listP.append(i)
		j = 1
		while i * j < limitN:
			P[i * j] = 1
			j += 1
Ans = list(map(str, filter(lambda x: x % 5 == 1, listP)))
print(' '.join(Ans[0:N]))


N = int(input())
MAXN = 66666
sieve = [0, 0] + [1] * MAXN
p = 2
while p * p <= MAXN:
	if sieve[p]:
		for q in range(2 * p, MAXN + 1, p):
			sieve[q] = 0
	p += 1
ans = []
for n in range(11, MAXN, 10):
	if sieve[n]:
		ans.append(n)
		if len(ans) == N:
			break
print(*ans)


N = int(input())
n = 55555
a = [-1, -1, 0] + [0] * (n - 2)
i = 2
while i * i <= n:
	if a[i] == 0:
		a[i] = 2
		b = i * 2
		while b <= n:
			a[b] = -1
			b += i
	i += 1
one = [x for x in range(2, n + 1) if a[x] != -1 and x % 5 == 1]
print(*one[0:N])


N = int(input())
l = []
for i in range(11, 55556)[::10]:
	l.append(i)
	for num in range(2, --int(i ** 0.5 // 1) + 1):
		if i % num == 0:
			l.pop(-1)
			break
print(*l[:N])


N = 55556
dp = [1] * (N + 1)
dp[0] = dp[1] = 0
for i in range(2, N + 1):
	if dp[i]:
		for j in range(i * i, N + 1, i):
			dp[j] = 0
five_prime = []
for i in range(N):
	if dp[i] == 1:
		if i % 5 == 1:
			five_prime.append(str(i))
N = int(input())
print(' '.join(five_prime[:N]))


import math
N = int(input())
ans_array = [2]
num = 7
while len(ans_array) != N:
	for i in range(2, int(math.sqrt(num)) + 1):
		if num % i == 0:
			break
	else:
		ans_array.append(num)
	num += 5
ans_str = ' '.join(map(str, ans_array))
print(ans_str)


N = int(input())
n = 55555
primes = set(range(3, n + 1, 2)) | set([2])
for i in range(3, int(n ** 0.5 + 1)):
	primes.difference_update(range(i * 3, n + 1, i * 2))
primes = list(primes)
a = []
for i in primes:
	if i % 10 == 1:
		a.append(i)
		if len(a) == N:
			break
print(*a)


N = int(input())
prime = []
for i in range(10, 1145148101919 + 1):
	a = True
	for g in range(2, i - 1):
		if i % g == 0:
			a = False
			break
	if a:
		if i % 5 == 1:
			prime.append(i)
	if len(prime) == 55:
		break
print(*prime[:N])


import math
N = int(input())
prime = []
for i in range(2, 55556):
	flag = True
	for j in range(2, int(math.sqrt(i)) + 1):
		if i % j == 0:
			flag = False
			break
	if flag and i % 5 == 1:
		prime.append(i)
print(' '.join(map(lambda x: str(x), prime[:N])))


N = int(input())
r = 55555
mp = [1] * (r + 1)
i = 2
while 2 * i <= r:
	j = 2
	while i * j <= r:
		mp[i * j] = 0
		j += 1
	i += 1
k = 0
l = 1
rlt = []
while k < N:
	if mp[30 * l - 1] == 1:
		rlt.append(30 * l - 1)
		k += 1
	l += 1
print(' '.join(map(str, rlt)))


n = int(input())
prime5 = []
for i in range(1, 5600):
	a = i * 10 + 1
	flag = True
	for j in range(3, int(a ** 0.5) + 1):
		if a % j == 0:
			flag = False
	if flag:
		prime5.append(a)
print(*prime5[:n])


n = 55555
a = int(input())
primes = set(range(2, n + 1))
for i in range(2, int(n ** 0.5 + 1)):
	primes.difference_update(range(i * 2, n + 1, i))
primes = list(primes)
b = []
for i in primes:
	if i % 5 == 3:
		b.append(i)
print(*b[:a])


def check(n):
	i = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += 1
	return True
n = int(input())
a = [2]
i = 6
while i <= 55555:
	if check(i):
		a.append(i)
	i += 5
for i in range(n):
	print(a[i], end=' ')


primes = []
for n in range(6, 55556, 5):
	k = 2
	while k * k <= n:
		if not n % k:
			break
		k += 1
	else:
		primes.append(n)
print(*primes[:int(input())])


def isprime(n):
	for i in range(2, n + 1):
		if n % i == 0:
			return False
		if i * i > n:
			break
	return True
n = int(input())
s = []
for i in range(2, 55556):
	if isprime(i) and i % 5 == 1:
		s.append(i)
		if len(s) == n:
			break
print(*s)