from itertools import *

inf = open("cipher.in", "r")
ouf = open("cipher.out", "w")

n = int(inf.readline())

a = [i for i in range(1, n + 1)]
ans = []
for b in permutations(a):
	if b[0] != 1:
		break
	ans += b + b

print(len(ans), file=ouf)
print(" ".join([str(x) for x in ans]), file=ouf)
	