from math import log
count = 1 ; i = 1 ; D = {}
n = 100000 # 20k:0.20s
m = int(n*(log(n)+log(log(n)))) # 100k:1.15s 200k:2.36s-7.8M
while count < n: # 400k:5.26s-8.7M
i += 2 # 800k:11.21-7.8M
if i not in D: # 1mln:13.20-7.8M (n^1.1)
count += 1
#print(i) ,
#if count%20==0: print ""
k = i*i
if k > m: break
while k <= m:
D[k] = 0
k += 2*i
while count < n:
i += 2
if i not in D: count += 1
if i >= m: print "invalid: top value estimate too small",i,m ; error
print i,m
ZnJvbSBtYXRoIGltcG9ydCBsb2cKCmNvdW50ID0gMSA7IGkgPSAxIDsgRCA9IHt9Cm4gPSAxMDAwMDAgICAgICAgICAgICAgICAgICAgICAgICAjIDIwazowLjIwcyAKbSA9IGludChuKihsb2cobikrbG9nKGxvZyhuKSkpKSAgICMgMTAwazoxLjE1cyAyMDBrOjIuMzZzLTcuOE0gCndoaWxlIGNvdW50IDwgbjogICAgICAgICAgICAgICAgICAjICAgICAgICAgICAgNDAwazo1LjI2cy04LjdNIAogICAgICAgIGkgKz0gMiAgICAgICAgICAgICAgICAgICAgIyAgICAgICAgICAgIDgwMGs6MTEuMjEtNy44TSAKICAgICAgICBpZiBpIG5vdCBpbiBEOiAgICAgICAgICAgICMgICAgICAgICAgICAxbWxuOjEzLjIwLTcuOE0gKG5eMS4xKQogICAgICAgICAgICBjb3VudCArPSAxCiAgICAgICAgICAgICNwcmludChpKSAsCiAgICAgICAgICAgICNpZiBjb3VudCUyMD09MDogcHJpbnQgIiIKICAgICAgICAgICAgayA9IGkqaQogICAgICAgICAgICBpZiBrID4gbTogIGJyZWFrCiAgICAgICAgICAgIHdoaWxlIGsgPD0gbToKICAgICAgICAgICAgICAgIERba10gPSAwIAogICAgICAgICAgICAgICAgayArPSAyKmkKd2hpbGUgY291bnQgPCBuOgogICAgICAgIGkgKz0gMgogICAgICAgIGlmIGkgbm90IGluIEQ6IGNvdW50ICs9IDEKaWYgaSA+PSBtOiBwcmludCAiaW52YWxpZDogdG9wIHZhbHVlIGVzdGltYXRlIHRvbyBzbWFsbCIsaSxtIDsgZXJyb3IKcHJpbnQgaSxtICAgICA=