#Q199. 「一本通 6.2 例 1」Prime Distance

「一本通 6.2 例 1」Prime Distance

Description

Original source: Waterloo local, problem statement available at POJ 2689

Given two integers LL and RR, find the pair of adjacent prime numbers in the closed interval [L,R][L, R] with the smallest difference and the pair with the largest difference. If multiple pairs exist, output the one that appears first.

Input Format

Multiple test cases. Each line contains two integers LL and RR.

Output Format

Refer to the sample output for details.

Sample 1

2 17
14 17

2,3 are closest, 7,11 are most distant.
There are no adjacent primes.

Constraints and Hints

For all test cases, 1L<R<231,RL1061\le L\lt R\lt 2^{31}, R-L\le 10^6.