## DMOPC '21 Contest 5 P6 - Permutations & Primes

View as PDF

Points: 25 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem types

Given an integer , find the lexicographically smallest permutation of such that is prime for all , or report that no such permutation exists.

#### Input Specification

The first and only line of input contains a single integer .

#### Output Specification

If no such permutation exists, output on a line by itself. Otherwise, output space-separated integers , the lexicographically smallest permutation such that is prime for all .

#### Sample Input

3

#### Sample Output

1 3 2

#### Explanation

Note that , , and are all prime.