PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SP0000143. Hai hoán vị có tổng nguyên tố (Permutation Prime Sums)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Hai hoán vị có tổng nguyên tố (Permutation Prime Sums)

Permutation Prime Sums

Source: CSES

Version: Phuoc Hung OJ Extended

Problem Statement

Given nn, construct two permutations a,ba,b of 1,…,n1,\ldots,n such that ai+bia_i+b_i is prime for every index. Print IMPOSSIBLE if impossible. Any valid pair is accepted.

Input

One line containing nn.

Output

Two lines, each listing a permutation, or IMPOSSIBLE.

Subtask

  • Subtask 1 (20 points): 1≤n≤1001\le n\le100.
  • Subtask 2 (30 points): 1≤n≤100001\le n\le10000.
  • Subtask 3 (50 points): 1≤n≤1000001\le n\le100000.

Example

Input

5

Output

1 2 3 4 5
1 5 4 3 2

Explanation

For n=5n=5, the first permutation is 1,2,3,4,51,2,3,4,5 and the second is 1,5,4,3,21,5,4,3,2. The coordinate sums are 2,7,7,7,72,7,7,7,7, all prime.