P29540 [洛谷] [COCI2014-2015#4] CESTA
普及-
题目描述

Problem Description

Mirko has discovered a positive integer \( n \). Since Mirko likes the number 30, he wants to know the largest multiple of 30 that can be formed using the digits of \( n \).

Write a program to compute this number (if it does not exist, output -1).

Input Format

A single number \( n \).

Output Format

A single line containing the number as described in the problem.

Sample Input and Output

Sample Input #1

30

Sample Output #1

30

Sample Input #2

102

Sample Output #2

210

Sample Input #3

2931

Sample Output #3

-1

Notes

Data Constraints

For 100% of the data, the number of digits in \( n \) does not exceed \( 10^5 \).

Notes

This problem is translated from COCI2014-2015 CONTEST #4 T1 CESTA.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
30
样例输出
30