#t71. 数字滑滑梯加强版

数字滑滑梯加强版

Number Slide (Enhanced Version)

Problem Background

A group of children go to "Candy Land" to play on the slide. Because there are so many of them, the attendant makes the following rules:

  • At most 9 children are let in at a time; each child holds a different number of game tokens (at least 1, at most 9), and each token lets them play the slide once;
  • They queue from left to right, and the rightmost child plays first;
  • Each time they play, one token is consumed from the child who plays; a child with no tokens left leaves the slide;
  • After sliding down, children who still have tokens are polite and queue again in their original order, without cutting in line;
  • All children leave the slide only when they have used up all their tokens;
  • No new children join before all current children have left;

Problem Description

Now please write a program that outputs the order of the nn children each time they play.

For example, for 3 children holding 3, 2, 1 tokens respectively, their order each time is:

1: 321 (the front child who slid down originally had 1 token, pays 1, has 0 left, leaves)
2: 32 (the front child who slid down originally had 2 tokens, pays 1, has 1 left)
3: 13
4: 21
5: 2
6: 1

Input Format

The input gives a positive integer n  (0<n<1010)n\;(0 \lt n \lt 10^{10}), each digit representing the number of tokens held by one child.

Output Format

Output several lines, each line one ordering, preceded by an index, then an English colon ":", then a space, then a positive integer, representing the ordering this time.

Sample Input 1

24

Sample Output 1

1: 32
2: 13
3: 21
4: 2
5: 1

Sample Input 2

513

Sample Output 2

1: 251
2: 25
3: 42
4: 14
5: 31
6: 3
7: 2
8: 1