HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Chapter 3. Repetition structures > problem:


12. Wonder primes

Volume problems

• 04. Train
• 05. Factorial
• 06. X to the power of Y
• 07. Fibonacci Series
• 08. Binary to decimal
• 09. Decimal to binary
• 10. Maximum
• 11. Perfect numbers
• 12. Wonder primes
• 13. Round numbers
• 14. Tower of Happiness
• 2. Molecules

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/2000/2000/2000 ms. Memory limit 65000/65000/65000/65000 Kb.

Problem description

A wonder primeis a number that can be partitioned into two prime numbers, each of which has at least D digits and, of course, doesn't start with 0. When D=2, the number 11329 is a wonder prime(since it connects 113 and 29, both of which are prime). Your job is to find the first wonder prime greater than or equal to a supplied integer N when you are given D.

Input

There are two integers D and N on the first line (1 ≤ D ≤ 4, 0 < N ≤ 106).

Output

Write first wonder prime according to the description.

Example

stdin stdout

2 11328

11329

Для отправки решений необходимо выполнить вход.

www.contester.ru