PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SP0000112. In một số nguyên tố theo chu kỳ 500 (Printing some primes — Hard)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

In một số nguyên tố theo chu kỳ 500 (Printing some primes — Hard)

Printing some primes (Hard)

Source: SPOJ

Version: Phuoc Hung OJ Extended

Problem Statement

Consider all prime numbers smaller than 10910^9 sorted in increasing order as p1,p2,…,pmp_1,p_2,\ldots,p_m, where p1=2p_1=2.

Print only those whose 1-based positions are 1,501,1001,1501,…1,501,1001,1501,\ldots. Equivalently, print pkp_k if and only if k≡1(mod500)k\equiv1\pmod{500}. Print each chosen prime on its own line in increasing order.

Input

There is no input.

Output

Print every selected prime, one per line, with no index or other text.

Subtasks

  • Subtask 1 (100 points): Consider all primes 2≤p<1092\le p<10^9; output exactly the indices k≥1k\ge1 satisfying k≡1(mod500)k\equiv1\pmod{500}.

Examples

Input

Output (excerpt, not the complete output)

2
3581
7927
...
999978527
999988747
999999151

Explanation

The first prime is 22, the 501501-st is 35813581, and the 10011001-st is 79277927. Keep every 500500-th prime after the first. The ... line is a placeholder in this illustrative excerpt only; the submitted program must print all selected primes and must never print the ellipsis.