cho.sh
Notes
Loading...

Making the Best Phone Number

Time limit

2s

Memory limit

128 MB

Problem

Youngsik wants to share his new mobile phone number with friends in a form that is easy to remember. The phone number is a string of N digits, and it must be split with hyphens (-). Each group must contain exactly 2 or 3 digits.

Each group belongs to one of the following three types.

  1. O group: all digits in the group are the same. For instance, 000 and 77.
  2. G group: the group has length 3, and exactly two of its digits are the same. For instance, 030, 229, and 116.
  3. Z group: all digits in the group are different. For instance, 123 and 90.

The quality of a formatted phone number is defined as follows.

2 * (number of O groups) + (number of G groups)

Given Youngsik's phone number, output a valid formatting whose quality is as large as possible.

Input

The first line contains Youngsik's phone number.

The phone number consists only of digits from 0 to 9, and its length is between 2 and 1,000 inclusive.

Output

Output a valid formatting of the phone number with maximum quality.

Separate adjacent groups with hyphens (-). If there is more than one maximum-quality formatting, output the lexicographically smallest one. String comparison uses the following order.

- < 0 < 1 < 2 < 3 < 4 < 5 < 6 < 7 < 8 < 9

Hint

For the first visible test, the phone number can be split in several ways.

  • 508-86-38: quality 0
  • 50-886-38: quality 1
  • 50-88-638: quality 2

Therefore the maximum-quality formatting is 50-88-638.