We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

- All Contests
- ProjectEuler+
- Project Euler #62: Cubic permutations

# Project Euler #62: Cubic permutations

# Project Euler #62: Cubic permutations

_{This problem is a programming version of Problem 62 from projecteuler.net}

The cube, , can be permuted to produce two other cubes: and .

In fact, is the smallest cube which has exactly three permutations of its digits which are also cube.

You are given , find the smallest cube for which exactly permutations of its digits are cube of some number which is . If there are multiple sets, print the minimal element of each in sorted order.

**Input Format**

Input contains two space separated integers and .

**Constraints**

**Output Format**

Print the answer corresponding to the test case. If there are more than one number, print them on separate lines.

**Sample Input**

```
1000 3
```

**Sample Output**

```
41063625
```