Vla-tko, Vla-tko, Vla-tko!
Nobody comes to Vlatko's office hours anymore. Angered, enraged and disgruntled, Vlatko's revenge is a convenient task for COCI:
You are given an infinite arithmetic sequence , defined for all natural numbers . We want to find a sequence of distinct natural numbers less than or equal to such that the corresponding members of sequence all have the same sum of digits in base .
Please note: Every positive integer can be written in base as follows: create the unique string , where for each , and the equation is satisfied. The sum of digits is given with .
Input Specification
The first line of input contains four integers , , and .
Output Specification
The first and only line of output must contain the required numbers, separated by spaces, in an arbitrary order.
Please note: you must output the numbers , not numbers . All numbers in the output should be less than or equal to .
The input data will be such that a solution that meets the given conditions exists.
Sample Input 1
5 3 2 2
Sample Output 1
2 5
Explanation for Sample Output 1
One of the possible sequences is the sequence in the output. The corresponding members of the arithmetic sequence are and . The format of number in base is , whereas the format of number in base is . The sum of digits in both formats is equal to .
Sample Input 2
2 1 10 3
Sample Output 2
2 20 200
Explanation for Sample Output 2
The corresponding members of the sequence are , , and . Each of the numbers' digits, written in base , sum up to .
Comments