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

#SP0000097. Bộ sinh số nguyên tố (Prime Generator)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Bộ sinh số nguyên tố (Prime Generator)

Prime Generator

Source: SPOJ

Version: Phuoc Hung OJ Extended

Problem Statement

Given integers LL and RR, list all prime numbers in the closed interval [L,R][L,R], including both endpoints. A prime is an integer greater than 11 with exactly two distinct positive divisors. Output the primes in increasing order, one per line. If there are no primes in the interval, output nothing.

Skip all non-primes. If no primes exist, the result is an empty sequence.

Input

One line contains two integers LL and RR, the inclusive left and right endpoints of the interval.

Output

Print each prime in increasing order on its own line. If none exist, print nothing.

Subtasks

  • Subtask 1 (20 points): 1≤L≤R≤100001\le L\le R\le 10000; R−L≤500R-L\le 500.
  • Subtask 2 (30 points): 1≤L≤R≤100000001\le L\le R\le 10000000; R−L≤10000R-L\le 10000.
  • Subtask 3 (50 points): 1≤L≤R≤10000000001\le L\le R\le 1000000000; R−L≤100000R-L\le 100000.

Examples

Input

1 10

Output

2
3
5
7

Explanation

The number 11 is not prime. The primes in [1,10][1,10] are 2,3,5,72,3,5,7; the other numbers greater than 11 are composite. Therefore, print these four numbers in increasing order.