#C11771. Expand Term Frequency String
Expand Term Frequency String
Expand Term Frequency String
You are given a string that represents a sequence of letter and digit pairs. Each pair consists of a letter and a single digit (0-9) which represents the frequency of that letter. Your task is to expand the string by repeating each letter according to its frequency indicated by the following digit.
For instance, if the input is a3b2c1
, then the output should be aaabbc
because the letter 'a' is repeated 3 times, 'b' 2 times, and 'c' 1 time.
The input consists of multiple test cases. For each test case, output the expanded string on a new line.
Formally, given a string S which can be expressed as S = L1F1L2F2...LnFn, where Li is a character and Fi (expressed as a digit) is its frequency, the result is:
\(\text{result} = L_{1}^{F_{1}} L_{2}^{F_{2}} \ldots L_{n}^{F_{n}}\)
inputFormat
The first line of input contains an integer T
(1 ≤ T ≤ 100), representing the number of test cases.
Each of the next T lines contains a non-empty string representing the term frequency sequence. Each string is formed by alternating letters and single-digit numbers.
outputFormat
For each test case, print the expanded string on a separate line. If the frequency of all characters is 0, output an empty line.
## sample2
a3b2c1
x1y2z3
aaabbc
xyyzzz
</p>