#K49592. Digit Sum Sequence

    ID: 28676 Type: Default 1000ms 256MiB

Digit Sum Sequence

Digit Sum Sequence

You are given two integers a and n. Your task is to generate a sequence of n numbers where the first element is a and every subsequent element is computed as follows:

\( s_1 = a \) and for \( i \geq 1 \), \[ s_{i+1} = s_i + \sum_{d \in \text{digits}(s_i)} d \]

For example, if a = 5 and n = 5, the resulting sequence is 5, 10, 11, 13, 17 because:

  • \( 5 \) stays as 5.
  • \( 5 + (5) = 10 \).
  • \( 10 + (1+0) = 11 \).
  • \( 11 + (1+1) = 13 \).
  • \( 13 + (1+3) = 17 \).

The generated sequence should be printed as space-separated values, one line per test case.

inputFormat

The input is read from stdin and consists of multiple test cases. The first line contains a single integer T indicating the number of test cases. Each of the following T lines contains two integers a and n separated by space.

For example:

2
5 5
12 4

outputFormat

For each test case, output a single line containing the generated sequence of n numbers. The numbers in the sequence should be space-separated. The output is written to stdout.

## sample
1
5 5
5 10 11 13 17