Crazy numbers

Given three natural numbers bb, dd and nn, let us say that a natural number xx is crazy if xx is a multiple of nn, and xx represented in base bb

Given bb, dd and nn, can you find all crazy numbers?

Input

Input consists of several cases, each one with bb, dd and nn. You can assume 3b103 \le b \le 10, d1d \ge 1, and n<bd1017n < b^d \le 10^{17}.

Output

For every case, print in order and with exactly dd digits all crazy numbers in base bb, followed by a line with ten dashes. All given cases are such that there are between 1 and 100 crazy numbers.

Observation

The expected solution requires less than 0.1 seconds to solve Sample input 2.

Problem information

Author: Salvador Roura

Generation: 2026-01-25T10:35:02.904Z

© Jutge.org, 2006–2026.
https://jutge.org