Problem:
 Score : 100 points    Problem Statement There are N persons, conveniently numbered 1 through N . They will take 3y3s Challenge for N-1 seconds.  During the challenge, each person must look at each of the N-1 other persons for 1 seconds, in some order.  If any two persons look at each other during the challenge, the challenge ends in failure.  Find the order in which each person looks at each of the N-1 other persons, to be successful in the challenge.      Constraints  2 \leq N \leq 100         Input The input is given from Standard Input in the following format:  N       Output If there exists no way to be successful in the challenge, print -1 .  If there exists a way to be successful in the challenge, print any such way in the following format:  A_{1,1}  A_{1,2}  ...  A_{1, N-1}  A_{2,1}  A_{2,2}  ...  A_{2, N-1} : A_{N,1}  A_{N,2}  ...  A_{N, N-1}   where A_{i, j} is the index of the person that the person numbered i looks at during the j -th second.      Judging The output is considered correct only if all of the following conditions are satisfied:   1 \leq A_{i,j} \leq N  For each i , A_{i,1}, A_{i,2}, ... , A_{i, N-1} are pairwise distinct.  Let X = A_{i, j} , then A_{X, j} \neq i always holds.         Sample Input 1 7      Sample Output 1 2 3 4 5 6 7
5 3 1 6 4 7
2 7 4 1 5 6
2 1 7 5 3 6
1 4 3 7 6 2
2 5 7 3 4 1
2 6 1 4 5 3       Sample Input 2 2      Sample Output 2 -1

Solution (Python):
n = int(input())
if n == 2:
    print(-1)
    exit()
if n % 2 == 1:
    for i in range(n):
        print(" ".join([str((item + i + 1) % n + 1) for item in range(n-1)]))
else:
    for i in range(n):
        ans = [(item + i + 1) % n + 1 for item in range(n-1) if item != n // 2 - 1]
        ans.insert(0, (n // 2 + i) % n + 1)
        if i < n // 2:
            ans[0], ans[1] = ans[1], ans[0]
        print(" ".join([str(item) for item in ans]))

Solution (Python):
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines

import numpy as np

N = int(readline())

def F(N):
    if N == 4:
        return np.array([[3,2,4],[3,4,1],[4,1,2],[2,1,3]])
    if N&1:
        x = np.arange(N)[:,None] + np.arange(N)[None,:]
        return (x[:,1:]%N)+1
    M = N//2
    x = F(M)
    arr = np.empty((N,N-1),np.int32)
    arr[0:M,0:M-1] = x
    arr[M:N,0:M-1] = x+M
    for n in range(M-1,N-1):
        arr[0:M,n] = np.arange(M) + n
        arr[M:N,n] = np.arange(M) + (1-n)        
    arr[:M,M-1:] %= M
    arr[:M,M-1:] += M+1
    arr[M:,M-1:] %= M
    arr[M:,M-1:] += 1
    return arr

if N == 2:
    print(-1)
    exit()

x = F(N)
print('\n'.join(' '.join(row) for row in x.astype(str)))

Solution (Python):
n = int(input())
if n==2: print(-1)
else:
	for i in range(1,n+1):
		num = 0
		if i%2==1:
			for j in range(1,n+1):
				if i!=j and num!=n-2:
					print(j,end=" ")
					num += 1
				elif i!=j:
					print(j)
					break
		else:
			if i==n: print(n-1,end=" ")
			else: print(n,end=" ")
			for j in range(1,n+1):
				if i!=j and num!=n-3:
					print(j,end=" ")
					num += 1
				elif i!=j:
					print(j)
					break

Solution (Python):
N = int(input())
if N == 2:
    print(-1)
    exit()

ans = [[0 for j in range(N-1)] for i in range(N)]
for i in range(N):
    for j in range(N-1):
        ans[i][j] = (i+j+1)%N + 1

if N%2 == 0:
    m = N//2
    for i in range(m,N):
        ans[i][m],ans[i][m-1] = ans[i][m-1],ans[i][m]

for row in ans:
    print(' '.join(map(str,row)))

Solution (Python):
n=input()
for i in range(n-2/n):j=n;exec"print-(n<3)or(i-~(j-2^(n%2<(j<n>i*2))))%n+1,;j-=1;"*~-n+"print"

Solution (Python):
n=input()
for i in range(n-2/n):
 for j in range(n-1):print-(n<3)or(i-~(j^(n%2<(j+2<n>i*2))))%n+1,
 print

Solution (Python):
n=input()
for i in range(n-2/n):print-(n<3)or" ".join(`(i-~(j^(n%2<(j+2<n>i*2))))%n+1`for j in range(n-1))

Solution (Python):
n=input();print-(n<3)or"\n".join(" ".join(`(1+i+(j^(n%2*n<j+2<n>i*2)))%n+1`for j in range(n-1))for i in range(n))

Solution (Python):
n=input();print-(n<3)or"\n".join(" ".join(`1+(i+(j^(n>=i*2and n%2<1and j<n-2)))%n`for j in range(n-1))for i in range(1,n+1))

Solution (Python):
n=input();print-(n==2)or"\n".join(" ".join(`1+(i+(j^(n>=i*2and n%2<1and j<n-2)))%n`for j in range(n-1))for i in range(1,n+1))

Solution (Python):
n=input();print-(n==2)or"\n".join(" ".join(`1+(i+(j^1)if n>=i*2 and n%2<1 and j<n-2 else i+j)%n`for j in range(n-1))for i in range(1,n+1))

Solution (Python):
n=input();print-(n==2)or"\n".join(" ".join(str(1+(i+(j^1)if n>=i*2 and n%2<1 and j<n-2 else i+j)%n)for j in range(n-1))for i in range(1,n+1))

Solution (Python):
n=input()
if n==2:print-1;exit(0)
r=range(n-1)
A=[[`1+(i+j+2)%n`for j in r]for i in[-1]+r]
i=n/2-1
if i:
 for j in range(i+1):A[j][i]=`j+i+1`;A[j][i-n]=`j+i+2`
print"\n".join(" ".join(e)for e in A)

Solution (Python):
n=input()
if n==2:print-1;exit(0)
r=range(n-1)
s=r+[n-1]
A=[[1+(i+j+1)%n for j in r]for i in s]
for i in r:
    for j in s:
        if A[A[j][i]-1][i]==j+1:
            A[j][i],A[j][i-n]=A[j][i-n],A[j][i]
print"\n".join(" ".join(map(str, e))for e in A)

Solution (Python):
N=input()
if N<3:print -1;exit()
a=range(1,N)
for i in range(N):
	print ' '.join(str(e+(i<e))for e in a)
	a=a[-1:]+a[:-1]