#C7003. Digit Sum Sequence

    ID: 50827 Type: Default 1000ms 256MiB

Digit Sum Sequence

Digit Sum Sequence

You are given two integers \(N\) and \(M\). Your task is to generate a sequence of \(M\) numbers where the first term is the sum of the digits of \(N\) and each subsequent term is the sum of the digits of the previous term.

The digit sum of a number \(n\) is defined as follows:

ds(n)=i=1kdi\text{ds}(n) = \sum_{i=1}^{k} d_i

For example, if \(N = 987654321\) and \(M = 3\), then:

  • The first term is \(\text{ds}(987654321)=45\).
  • The second term is \(\text{ds}(45)=9\).
  • The third term is \(\text{ds}(9)=9\).

Print the sequence (\(M\) numbers) separated by a single space.

inputFormat

The input consists of a single line containing two integers \(N\) and \(M\) separated by a space. \(N\) is a positive integer, and \(M\) is the number of terms to generate in the sequence.

outputFormat

Output exactly \(M\) numbers separated by a space. These numbers represent the sequence of digit sums computed as described.

## sample
123 5
6 6 6 6 6