N, M, K = map(int, input().split()) for i in range(N): for j in range(N): print((i * K + j) % M + 1, end = "\n" if j == N - 1 else " ")