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

#SP0000191. Số vừa nguyên tố vừa đối xứng (PP Numbers)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Số vừa nguyên tố vừa đối xứng (PP Numbers)

PP Numbers

Phuoc Hung OJ problem: PRIME000196
Reference: SPOJ MB1
Adaptation: one original query per PHOJ execution; subtasks are PHOJ-specific groups.

Problem statement

A PP number is both prime and a decimal palindrome. Let vv be the nn-th PP number in increasing order. Let mm be the product of all nonzero digits of vv. Print vv and the mm-th prime, counting from 22.

Input

One integer nn. (PHOJ version: one query from the original multi-case input.)

Output

Print vv and pmp_m separated by one space.

Subtasks

  • Subtask 1 (20 points): 1≤n≤201\le n\le20.
  • Subtask 2 (30 points): 21≤n≤7021\le n\le70.
  • Subtask 3 (50 points): 71≤n≤11371\le n\le113.

Example

Input

5

Output

11 2

Explanation: The PP sequence begins 2,3,5,7,112,3,5,7,11, so v=11v=11. Its nonzero-digit product is 11; the first prime is 22.