#include <bits/stdc++.h>
using namespace std;
const int maxn = 120;
int a[maxn];
int b[maxn];
int c[maxn][maxn];
int vis[maxn][maxn];
int main() {
  int n, m, h;
  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++) {
    int flag = 0;
    for (int j = 1; j <= m; j++) {
      if (a[j] == b[i] && !vis[i][j] && c[i][j] == 1) {
        flag = 1;
        c[i][j] = b[i];
        vis[i][j] = 1;
        break;
      }
    }
    for (int j = 1; j <= m; j++) {
      if (!flag && a[j] > b[i] && !vis[i][j] && c[i][j] == 1) {
        c[i][j] = b[i];
        vis[i][j] = 1;
        break;
      }
    }
  }
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      if (c[j][i] == 1 && !vis[j][i] && a[i] <= b[j]) {
        c[j][i] = a[i];
        vis[j][i] == 1;
        break;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (j != m)
        printf("%d ", c[i][j]);
      else
        printf("%d\n", c[i][j]);
    }
  }
  return 0;
}
