#ABC475D. 字母算式素数 / Alphametic Prime

字母算式素数 / Alphametic Prime

Problem Statement

You are given a string SS consisting of lowercase English letters. If there exists a prime number PP satisfying the following condition, find one such PP.

Condition: Let TT be the string representing PP in decimal notation without an extra leading 0. Then, ∣S∣=∣T∣|S|=|T|, and for every 1≤i<j≤∣S∣1\leq i< j \leq |S|, we have Si=SjS_i=S_j if and only if Ti=TjT_i=T_j.

Constraints

  • SS is a string of length between 11 and 77 (inclusive) consisting of lowercase English letters.

Input

The input is given from Standard Input in the following format:

  • SS

Output

If there is no prime number satisfying the condition in the problem statement, output -1. If one exists, output one such prime number. If there are multiple solutions, any of them will be accepted.

motor
10607

Besides this, for example, outputting 40709 would also be accepted. However, for example, 81817 does not satisfy the condition, so it would not be accepted.

byebye
-1

If there is no prime number satisfying the condition, output -1.

coconut
1010237