def get_list(ty=int): return list(map(ty, input().split())) def get_int(): return int(input()) def get_str(): return input() N = get_int() for i in range(N): ans = [] for j in range(1, N + 1): ans.append((i + j) % 4 + 1) print(*ans)