#!/usr/bin/env PyPy3 from collections import Counter, defaultdict, deque import itertools import re import math from functools import reduce import operator import bisect import heapq import functools mod=10**9+7 import sys input=sys.stdin.readline h,w=map(int,input().split()) r=list(map(int,input().split())) c=list(map(int,input().split())) ans = [[1] * w for _ in range(h)] ans[0][0] = 10 ** 8 for i in range(h): ri = r[i] for j in range(ri): ans[i][j] += j + 1 for row in ans: print(*row) for i in range(w): ci = c[i] for j in range(ci): ans[j][i] += 10 ** 5 * (j+1) for row in ans: print(*row)