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

#SP0000152. Số nguyên tố mang mẫu chữ cái (Alphametic Prime)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Số nguyên tố mang mẫu chữ cái (Alphametic Prime)

Alphametic Prime

Source: AtCoder — abc475_d

Version: Phước Hưng OJ Extended; one input file per judge run.

Problem Statement

Given a lowercase string SS of length at most 7, find a prime PP with the same length and exactly the same equality pattern among digit positions as among letters of SS. Print any valid prime, or -1 if impossible.

Input

One lowercase string SS.

Output

Print any matching prime, or -1.

Subtask

  • Subtask 1 (20 points): 1≤∣S∣≤31\le |S|\le 3, lowercase English letters.
  • Subtask 2 (30 points): 1≤∣S∣≤51\le |S|\le 5, lowercase English letters.
  • Subtask 3 (50 points): 1≤∣S∣≤71\le |S|\le 7, lowercase English letters.

Example

Input

motor

Output

10607

Explanation

The example follows the mathematical conditions and the specified output format.