#include <bits/stdc++.h>
using namespace std;
int n, m, h, a[200], b[200], c[200][200], ans[200][200];
int main() {
  scanf("%d%d%d", &n, &m, &h);
  for (int i = 1; i <= m; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%d", &c[i][j]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (c[i][j] == 0)
        ans[i][j] = 0;
      else
        ans[i][j] = min(a[j], b[i]);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j < m; j++) printf("%d ", ans[i][j]);
    printf("%d\n", ans[i][m]);
  }
  return 0;
}
