#include <bits/stdc++.h>
int n, m, h;
int 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]) continue;
      ans[i][j] = std::min(b[i], a[j]);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) printf("%d ", ans[i][j]);
    puts("");
  }
  return 0;
}
