Bike is interested in permutations. A permutation of length n is an integer sequence such that each integer from 0 to (n - 1) appears exactly once in it. For example, [0, 2, 1] is a permutation of length 3 while both [0, 2, 2] and [1, 2, 3] is not.

A permutation triple of permutations of length n (a, b, c) is called a Lucky Permutation Triple if and only if $\forall i(1 \leq i \leq n), a_{i} + b_{i} \equiv c_{i} \operatorname{mod} n$. The sign a_{i} denotes the i-th element of permutation a. The modular equality described above denotes that the remainders after dividing a_{i} + b_{i} by n and dividing c_{i} by n are equal.

Now, he has an integer n and wants to find a Lucky Permutation Triple. Could you please help him?


-----Input-----

The first line contains a single integer n (1 ≤ n ≤ 10^5).


-----Output-----

If no Lucky Permutation Triple of length n exists print -1.

Otherwise, you need to print three lines. Each line contains n space-seperated integers. The first line must contain permutation a, the second line — permutation b, the third — permutation c.

If there are multiple solutions, print any of them.


-----Examples-----
Input
5

Output
1 4 3 2 0
1 0 2 4 3
2 4 0 1 3

Input
2

Output
-1



-----Note-----

In Sample 1, the permutation triple ([1, 4, 3, 2, 0], [1, 0, 2, 4, 3], [2, 4, 0, 1, 3]) is Lucky Permutation Triple, as following holds:  $1 + 1 \equiv 2 \equiv 2 \operatorname{mod} 5$;  $4 + 0 \equiv 4 \equiv 4 \operatorname{mod} 5$;  $3 + 2 \equiv 0 \equiv 0 \operatorname{mod} 5$;  $2 + 4 \equiv 6 \equiv 1 \operatorname{mod} 5$;  $0 + 3 \equiv 3 \equiv 3 \operatorname{mod} 5$. 

In Sample 2, you can easily notice that no lucky permutation triple exists.

Difficulty: EASY
Tags: Mathematics

Implementation

Constructive algorithms

Starter code:

Solutions:
n = int(input())
if n % 2 == 0:
	print(-1)
else:
	print(*list(range(n)))
	print(*list(range(n)))
	print(*((i + i) % n for i in range(n)))


n = int(input())
if n % 2 == 0:
	print(-1)
else:
	print(*list(range(n)))
	print(*list(range(n)))
	print(*list(map(lambda x, y: (x + y) % n, list(range(n)), list(range(n)))))


n = int(input())
if n % 2 == 0:
	print(-1)
else:
	lista = list(range(n))
	saida = list([2 * x % n for x in lista])
	print(' '.join(map(str, lista)))
	print(' '.join(map(str, lista)))
	print(' '.join(map(str, saida)))


n = int(input())
if n % 2:
	a = [i for i in range(n)]
	b = [i for i in range(n)]
	c = [(a[i] + b[i]) % n for i in range(n)]
	print(*a)
	print(*b)
	print(*c)
else:
	print(-1)


n = int(input())
if n % 2 == 1:
	for i in range(n):
		print(i, end=' ')
	print()
	for i in range(n):
		print((i + 1) % n, end=' ')
	print()
	for i in range(n):
		print((i + (i + 1) % n) % n, end=' ')
else:
	print(-1)


def prnt(j):
	for i in range(j):
		print(i, end=' ')
	print()
	return

def triplet(n):
	if n % 2 != 0:
		prnt(n)
		prnt(n)
		for i in range(n):
			num = i + i
			if num >= n:
				num = num - n
			print(num, end=' ')
	else:
		print('-1')
n = int(input())
triplet(n)


a = int(input())
if a % 2 == 0:
	print(-1)
elif a == 1:
	print('0\n0\n0')
else:
	z = [*range(a - 1, -1, -1)]
	z1 = [a - 2] + [*range(a - 3, -1, -1)] + [a - 1]
	print(*z)
	print(*z1)
	for i in range(a):
		print((z[i] + z1[i]) % a, end=' ')


n = int(input())
if n % 2 == 0:
	print(-1)
else:
	print(' '.join(map(str, range(n))))
	print(' '.join(map(str, range(n))))
	print(' '.join(map(str, [2 * x % n for x in range(n)])))


n = int(input())
if n % 2 == 0:
	print(-1)
else:
	print(' '.join(map(str, list(range(0, n)))))
	il = [0]
	for i in range(1, n):
		if i <= n // 2:
			il.append(n - 2 * i)
		else:
			il.append(n - 1 - 2 * (i - n // 2 - 1))
	print(' '.join(map(str, il)))
	print(' '.join(map(str, [(i + il[i]) % n for i in range(0, n)])))


n = int(input())
if n % 2 == 0:
	print('-1')
else:
	a = range(n)
	print(' '.join(map(str, a)))
	print(' '.join(map(str, a)))
	print(' '.join(map(lambda x: str((x[0] + x[1]) % n), zip(a, a))))


r = int(input())
if r % 2 == 0:
	print(-1)
elif r == 1:
	print(0)
	print(0)
	print(0)
else:
	for i in range(r):
		print(i, end=' ')
	print()
	i = r - 1
	while i >= 0:
		print(i, end=' ')
		i -= 2
	i = r - 2
	while i >= 0:
		print(i, end=' ')
		i -= 2
	print()
	for i in range(r - 1, -1, -1):
		print(i, end=' ')


n = int(input())
if n % 2 == 0:
	print(-1)
else:
	print(*range(n))
	print(*range(1, n), 0)
	print(*range(1, n, 2), *range(0, n, 2))


a = int(input())
t = ''
tt = ''
ttt = ''
if a % 2 != 0:
	for x in range(0, a):
		t = t + (str(x) + ' ')
	for x in range(0, a):
		tt = tt + (str(x) + ' ')
	for x in range(0, a):
		ttt = ttt + (str(2 * x % a) + ' ')
else:
	print(-1)
print(t)
print(tt)
print(ttt)


n = int(input())
arr = [i for i in range(n)]
ans = []
for i in range(n):
	ans.append(2 * i % n)
if sorted(ans) != arr:
	print(-1)
else:
	print(*arr)
	print(*arr)
	print(*ans)


def solve(n):
	a = []
	b = []
	c = []
	for i in range(n):
		a.append(i)
	for i in range(1, n):
		b.append(i)
	b.append(0)
	for i in range(n):
		if a[i] + b[i] < n:
			c.append(a[i] + b[i])
		elif a[i] + b[i] == n:
			c.append(0)
		else:
			c.append(a[i] + b[i] - n)
	if len(c) != len(set(c)):
		print(-1)
	else:
		print(' '.join(map(str, a)))
		print(' '.join(map(str, b)))
		print(' '.join(map(str, c)))

def __starting_point():
	n = int(input())
	solve(n)
__starting_point()


n = int(input())
if n % 2 == 0:
	print(-1)
elif n == 1:
	print(0)
	print(0)
	print(0)
else:
	p = [0] * n
	q = [0] * n
	w = [0] * n
	t = int(n / 2)
	for i in range(0, n):
		p[i] = i
		if i < t:
			q[i] = n - 2 - 2 * i
		else:
			q[i] = 4 * t - 2 * i
		if i <= n - 2:
			w[i] = n - 2 - i
		else:
			w[i] = n - 1
	for i in range(0, n):
		if i != n - 1:
			print(p[i], end=' ')
		else:
			print(p[i])
	for i in range(0, n):
		if i != n - 1:
			print(q[i], end=' ')
		else:
			print(q[i])
	for i in range(0, n):
		if i != n - 1:
			print(w[i], end=' ')
		else:
			print(w[i])


n = int(input())
if n % 2 == 0:
	print('-1')
else:
	a = list(range(n))
	print(' '.join(map(str, a)))
	print(' '.join(map(str, a)))
	print(' '.join([str((x[0] + x[1]) % n) for x in zip(a, a)]))


from itertools import zip_longest
n = int(input())
a = list(range(n))
b = list(range(n))
c = []
for (i, j) in zip_longest(a, b):
	c.append((i + j) % n)
if len(c) != len(set(c)):
	print(-1)
else:
	print(*a)
	print(*b)
	print(*c)


n = int(input())
if n % 2 == 0:
	print(-1)
	exit()
print(*range(0, n))
print(*range(0, n))
for x in range(n):
	print(2 * x % n, end=' ')
print()


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect, insort
from time import perf_counter
from fractions import Fraction
import copy
from copy import deepcopy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass

def pmat(A):
	for ele in A:
		print(*ele, end='\n')
n = L()[0]
A = [i for i in range(n)]
B = [(i - 1) % n for i in range(n)]
if n % 2 == 0:
	print(-1)
else:
	print(*A)
	print(*B)
	C = [(A[i] + B[i]) % n for i in range(n)]
	print(*C)
endtime = time.time()


n = int(input())
if n % 2 == 0:
	print(-1)
	return
print(*list(range(n)))
print(*list(range(n)))
res = []
for i in range(n):
	res += [2 * i % n]
print(*res)


n = int(input())
if n & 1:
	t = ' '.join(map(str, range(n)))
	print(t)
	print(t[2:] + ' 0')
	print(' '.join(map(str, list(range(1, n, 2)) + list(range(0, n, 2)))))
else:
	print(-1)