def ifrom(n):
while True:
yield n
n += 1
def sieve(n, xs):
for i in xs:
if i % n != 0:
yield i
def primes():
xs = ifrom(2)
while True:
n = next(xs)
yield n
xs = sieve(n, xs)
if __name__ == '__main__':
for i, p in zip(range(20), primes()):
print(p, end=' ')
ZGVmIGlmcm9tKG4pOgogICAgd2hpbGUgVHJ1ZToKICAgICAgICB5aWVsZCBuCiAgICAgICAgbiArPSAxCgpkZWYgc2lldmUobiwgeHMpOgogICAgZm9yIGkgaW4geHM6CiAgICAgICAgaWYgaSAlIG4gIT0gMDoKICAgICAgICAgICAgeWllbGQgaQoKZGVmIHByaW1lcygpOgogICAgeHMgPSBpZnJvbSgyKQogICAgd2hpbGUgVHJ1ZToKICAgICAgICBuID0gbmV4dCh4cykKICAgICAgICB5aWVsZCBuCiAgICAgICAgeHMgPSBzaWV2ZShuLCB4cykKICAgICAgICAKaWYgX19uYW1lX18gPT0gJ19fbWFpbl9fJzogICAgICAgCiAgICBmb3IgaSwgcCBpbiB6aXAocmFuZ2UoMjApLCBwcmltZXMoKSk6CiAgICAgICAgcHJpbnQocCwgZW5kPScgJykK