Comma Sprinkler

Given a text, repeatedly add commas before or after every occurrence of a word that already has a comma on that side, until nothing changes; print the result.

Medium6GraphBFSStringImplementationNo attempts yetTime limit8sMemory limit1024 MB

Problem

The English rules for comma placement are complicated, and they are often ambiguous. Some people ignore them, some invent their own, and some use no commas at all.

Doctor Comma Sprinkler removed the ambiguity with a fixed procedure. Her rules for adding commas to a piece of text that is already written are these.

  1. If a word anywhere in the text is preceded by a comma, find every occurrence of that word and put a comma before each of them. An occurrence that is the first word of a sentence, or that already has a comma before it, is left alone.
  2. If a word anywhere in the text is followed by a comma, find every occurrence of that word and put a comma after each of them. An occurrence that is the last word of a sentence, or that already has a comma after it, is left alone.
  3. Repeat rules 1 and 2 until neither rule adds a comma.

Write a program that applies the procedure to the given text.

The first example shows how the rules chain. In the second sentence spot is followed by a comma, so a comma goes after spot in the third sentence as well. The spot in the first sentence stays as it is, because it is the last word of that sentence. The sit in the second sentence has a comma before it, so a comma goes before the sit in the first sentence, but not before the sit that opens the second sentence. Once the spot in the third sentence takes a comma, the first here has a comma before it, so the second here takes one too. After that no rule adds anything.

Input

The first and only line contains the text. It has at least 2 and at most 1,000,000 characters, and every character is a lowercase letter, a comma, a period, or a space. A word is a maximal run of letters within the text.

The text satisfies the following.

  • The text begins with a word.
  • Between two consecutive words there is a single space, a comma followed by a space, or a period followed by a space. A period ends a sentence, and the next word begins a new one.
  • The last word of the text is followed by a period, with no trailing space.

Output

Print the text after Doctor Sprinkler's procedure has been applied to it.