#C13618. Repeat Words

    ID: 43176 Type: Default 1000ms 256MiB

Repeat Words

Repeat Words

Given a list of pairs, each consisting of a word and an integer, construct a string by repeating each word as many times as indicated by the integer and joining them with a single space. For each pair ( (w, k) ), the word ( w ) should appear ( k ) times in the output in the order given. If ( k = 0 ), the word is omitted from the resulting string.

inputFormat

The input is provided via standard input. The first line contains an integer ( n ) specifying the number of word-count pairs. Each of the following ( n ) lines contains a word and an integer separated by a space.

outputFormat

Print a single line to standard output containing the words repeated according to their counts, separated by a single space. If there are no words to output, print an empty line.## sample

3
word1 3
word2 1
word3 2
word1 word1 word1 word2 word3 word3