from collections import defaultdict
def E(H, W, N, h, w, A):
loc = defaultdict(lambda: dict(minx=W, maxx=0, miny=H, maxy=0))
for i, row in enumerate(A):
for j, a in enumerate(row):
loc[a]["minx"] = min(loc[a]["minx"], j)
loc[a]["maxx"] = max(loc[a]["maxx"], j)
loc[a]["miny"] = min(loc[a]["miny"], i)
loc[a]["maxy"] = max(loc[a]["maxy"], i)
for i in range(H - h + 1):
ans = []
for j in range(W - w + 1):
ans.append(0)
for v in loc.values():
if (
v["minx"] >= j and
v["maxx"] <= j + w - 1 and
v["miny"] >= i and
v["maxy"] <= i + h - 1
): pass
else: ans[-1] += 1
print(*ans)
H, W, N, h, w = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
E(H, W, N, h, w, A)