nr01
Be there n a positive integer (given in decimal system) and b the base of a numeration system.

Task
Write a program that displays in decimal system all numbers smaller than or equal to n, which written in the numeration system having the base b use only digits 0 and 1.

Input Data
Input file nr01.in contains a single line with two positive integers separated by a space n b (with the meaning from the problem statement).

Output Data
Output file nr01.out will contain all numbers smaller than or equal to n written in decimal system, numbers which written in the numeration system having the base b use only digits 0 and 1, one number per line. The numbers will be written in ascending order.

Constraints

1 < n <= 100 000 000
2 <= b <= 256

Examples

nr01.in nr01.out

64 4

0
1
4
5
16
17
20
21
64

Time limit: 0.1 seconds/test

prof. Emanuela Cerchez
Computer Science High School "Grigore Moisil" Iasi
Contact:emanuela.cerchez@gmail.com