Let
x – a positive integer, and
k – natural number from 1 to 10. Let
s(x, k) be equal to the sum of the digits of the number
x represented in base number system
k.< /div>
Specified n numbers a1, a2, ..., an. It is necessary to calculate the sequence bi using the formula \(b_i = s(a_i, k_1) \cdot s(a_i, k_2)\ ). After that, sort the sequence bi in non-descending order.
Input
The first line contains three integers: n, k1, k2 code> (\(1 <= n <= 1000\), \(2 <= k_1, k_2 <= 10\)). The second line contains n integers: ai (\(1 <= a_i < = 10^9\)).
Output
In response, output
n numbers –
bi in the required order.
Examples
| # |
Input |
Output |
| 1 |
9 10 10
1 2 3 4 5 6 7 9 8
|
1 4 9 16 25 36 49 64 81 |
| 2 |
10 2 2
1 2 4 8 16 32 64 128 256 512
|
1 1 1 1 1 1 1 1 1 1 |