Under construction

Still being built. Things may change

Accounting Numeral System

Time limit1sMemory limit1024 MB

Summary
Given n and m, find the unique strictly increasing indices x_1 to x_m such that n is the sum of C(x_i, i), printed from x_m down to x_1.
Level

Medium6 of 10

Topics
Combinatorics, Greedy, Binary search
Solved
No attempts yet

Problem

The Accounting Numeral System is the top accounting system in the whole world. Its creator, Dr. Ceizenpok, is the leading expert of the respective authority.

In the accounting numeral system with base mm, a positive integer nn is written as a sum of mm parts:

n=Cxmm+Cxm−1m−1+Cxm−2m−2+⋯+Cx11n = C_{x_m}^m + C_{x_{m-1}}^{m-1} + C_{x_{m-2}}^{m-2} + \cdots + C_{x_1}^1

Here x1,x2,…,xmx_1, x_2, \ldots, x_m are integers with 0≤x1<x2<⋯<xm0 \le x_1 < x_2 < \cdots < x_m. The numbers Ckm=k!m! (k−m)!C_k^m = \frac{k!}{m!\,(k-m)!} are called accounting indexes. Here 0!=10! = 1, and Ckm=0C_k^m = 0 if m>km > k.

The number nn is written as (xm)…(x2)(x1)‾\overline{(x_m) \ldots (x_2)(x_1)}. For example, 9 in base 3 is written as (4)(3)(2), because 9=C43+C32+C219 = C_4^3 + C_3^2 + C_2^1. The number 1 in base 2 is written as (2)(0), because 1=C22+C011 = C_2^2 + C_0^1.

Find the representation of the integer nn in the accounting numeral system with base mm.

Input

The only line contains two integers nn and mm (1≤n≤10161 \le n \le 10^{16}, 2≤m≤1 0002 \le m \le 1\,000).

Output

Print one line with mm space-separated integers xm,…,x2,x1x_m, \ldots, x_2, x_1 that form the representation of nn in the accounting numeral system. xmx_m is the leftmost number of the representation, and x1x_1 is the rightmost.

Examples2

  1. Example 1

    Input
    9 3
    
    Expected output
    4 3 2
    
  2. Example 2

    Input
    5 2
    
    Expected output
    3 2