#K47592. Prime Sum Pairs Circle

    ID: 28232 Type: Default 1000ms 256MiB

Prime Sum Pairs Circle

Prime Sum Pairs Circle

In this problem, you are given a positive integer (M) and are required to arrange the numbers from 1 to (M) in a circle so that the sum of every pair of adjacent numbers (including the pair formed by the last and the first element) is a prime number.

For example, if (M = 10), one valid arrangement is:
(2\ 1\ 4\ 3\ 8\ 5\ 6\ 7\ 10\ 9).

If no valid arrangement exists, you should output False.

Note: A prime number is a positive integer greater than 1 that has no positive divisors other than 1 and itself. All sums must be checked for primality using the classic definition.

inputFormat

The input is provided via standard input (stdin) and consists of a single integer (M) ((1 \le M \le 12), for example) representing the number of elements. (M) can be assumed to be small enough for a brute-force solution to pass.

outputFormat

Output the arrangement as a single line of numbers separated by a space if a valid arrangement exists. If there is no valid arrangement, output the string False (without quotes). The output should be written to standard output (stdout).## sample

10
2 1 4 3 8 5 6 7 10 9

</p>