h, w = map(int, input().split()) R = list(map(int, input().split())) C = list(map(int, input().split())) A = [[0] * w for _ in range(h)] for i in range(h): for j in range(w): A[i][j] = (i * w + j) * 100 A[0][0] = 10 ** 9 for i in range(1, h): A[i][0] = A[i][-R[i]] + 30 for j in range(1, w): A[0][j] = A[-C[j]][j] + 70 for row in A: print(*row)