#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int n, m, h;
vector<int> aux, aux2;
int vec[102][102];
int vis[102];
int vis2[102];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m >> h;
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    aux.push_back(a);
  }
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    aux2.push_back(a);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) cin >> vec[i][j];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (vec[i][j] != 0) {
        if (aux[j] == aux2[i]) {
          vis[i] = aux2[i];
          vis2[j] = aux[j];
          vec[i][j] = aux[j];
        } else {
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (vec[i][j] != 0) {
        if (aux[j] != aux2[i]) {
          if (!vis2[j]) {
            int maxi = 0;
            int maxi2 = 0;
            if (aux[j] > aux2[i])
              continue;
            else
              vec[i][j] = aux[j], vis2[j] = aux[j];
          } else if (!vis[i]) {
            if (aux2[i] > aux[j])
              continue;
            else
              vec[i][j] = aux2[i], vis[i] = aux[i];
          }
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) cout << vec[i][j] << " ";
    cout << "\n";
  }
  return 0;
}
