NOI Contest Archive

Archive / 2022 / Selection Test

Permission to Permute

Medium · National Olympiad in Informatics Sri Lanka - Screening Test 2022

Given n, find whether an arrangement of positive integers from 1 to n exists such that the absolute difference between adjacent integers is in the set {2,3,4}. If there exists such an arrangement, print it.

Input Format

Output Format

Constraints

Limits

Sample Input 0

4
10
6
13
2

Sample Output 0

9 6 10 8 4 7 3 1 5 2
5 3 6 2 4 1
13 9 7 11 8 4 1 3 5 2 6 10 12 
-1

Sample Input 1

2
1
5

Sample Output 1

-1
5 3 1 4 2