#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int res = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') res = res * 10 + ch - '0', ch = getchar();
  return res * f;
}
inline void write(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x < 10)
    putchar(x + '0');
  else {
    write(x / 10);
    putchar(x % 10 + '0');
  }
}
int n, m, h, a[110], b[110];
int main() {
  n = read();
  m = read();
  h = read();
  for (int i = 1; i <= m; i++) a[i] = read();
  for (int i = 1; i <= n; i++) b[i] = read();
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      int x = read();
      if (x == 0)
        putchar('0');
      else
        write(min(a[j], b[i]));
      putchar(' ');
    }
    puts("");
  }
  return 0;
}
