#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, h, m;
  cin >> n >> m >> h;
  int col[m], row[n];
  for (int i = 0; i < m; i++) {
    cin >> col[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> row[i];
  }
  int arr[n][m];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> arr[i][j];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (row[i] == col[j] && arr[i][j] == 1) arr[i][j] = row[i];
    }
  }
  for (int i = 0; i < m; i++) {
    int val = col[i];
    int index;
    int flag = 0;
    for (int j = 0; j < n; j++) {
      if (arr[j][i] == 1 && val <= row[j]) {
        index = j;
      }
      if (arr[j][i] == val) {
        flag = 1;
        break;
      }
    }
    if (flag == 0) arr[index][i] = val;
  }
  for (int i = 0; i < n; i++) {
    int val = row[i];
    int index;
    int flag = 0;
    for (int j = 0; j < m; j++) {
      if (arr[i][j] == 1 && val <= col[j]) {
        index = j;
      }
      if (arr[i][j] == val) {
        flag = 1;
        break;
      }
    }
    if (flag == 0) arr[i][index] = val;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) cout << arr[i][j] << " ";
    cout << endl;
  }
}
