Scramble Sort

No attempts yetTime limit1sMemory limit128 MB

Problem

You are given several lists, each containing a mix of words and integers. Sort each list according to the following rules.

  • All words must be in alphabetical order.
  • All integers must be in ascending numerical order.
  • If the $n$-th element was an integer it must stay an integer, and if it was a word it must stay a word. In other words, the pattern of integer/word positions is preserved and only the order within each group changes.

Words are compared case-insensitively, but each word keeps its original capitalization in the output. Integers may be negative.

Input

The input contains multiple lists, one per line. Within a line the elements are separated by a comma and a space (, ), and each list is terminated by a period (.). The input is terminated by a line containing only a single period.

Output

For each list, print the scramble-sorted list on its own line. Separate the elements with a comma and a space (, ) and end the line with a period (.).