- All Contests
- ProjectEuler+
- Project Euler #68: Magic N-gon ring

# Project Euler #68: Magic N-gon ring

# Project Euler #68: Magic N-gon ring

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

Consider the following "magic" ring, filled with the numbers to , and each line adding to nine.

Working clockwise, and starting from the group of three with the numerically lowest external node (4,3,2 in this example), each solution can be described uniquely. For example, the above solution can be described by the set: 4,3,2; 6,2,1; 5,1,3.

It is possible to complete the ring with four different totals: 9, 10, 11, and 12. There are eight solutions in total.

By concatenating each group it is possible to form 9-digit strings; the strings for a ring where total is are and .

Given , which represents the and the total print all concatenated solution strings in alphabetical sorted order.

**Note:** It is guaranteed that solution will exist for testcases.

**Input Format**

You are given and separated by a space.

**Constraints**

**Output Format**

Print the required strings each on a new line.

**Sample Input**

```
3 9
```

**Sample Output**

```
423531612
432621513
```