P27078 [AtCoder] String and Prime
提高
题目描述

Problem Description

Given a string $ S $. Perform a conversion from $ S $ to a number that satisfies the following conditions:

  • Each character in $ S $ is converted to one of the digits 1, 3, 5, 7, 9.
  • The same characters must be converted to the same digit, and different characters must be converted to different digits.

Can the string $ S $ be converted to a prime number under these conditions?

Input Format

The input is given from the standard input in the following format:

$ S $

  • A single line containing the string $ S $ ($1 \leq |S| \leq 10$).
  • Each character in $ S $ is a lowercase English letter.

Output Format

If a prime number conversion is possible, output one such prime number. If no prime number conversion is possible, output $ -1 $.

If there are multiple possible prime number conversions, any one of them will be considered correct.

Sample Input and Output

Sample Input #1

tit

Sample Output #1

131

Sample Input #2

titech

Sample Output #2

757319

Sample Input #3

tokyotech

Sample Output #3

-1

Notes/Hints

Sample Explanation 1

Other outputs such as $ 151 $, $ 171 $, $ 191 $, $ 313 $, ... will also be considered correct.

Sample Explanation 3

There are too many distinct characters, so it is impossible to construct a conversion that satisfies the conditions.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
tit
样例输出
131