#include <bits/stdc++.h>
using namespace std;
int n, m, h;
int nn[100], mm[100];
bool mat[100][100];
int ans[100][100];
int main() {
  cin >> n >> m >> h;
  for (int i = 0; i < m; i++) cin >> mm[i];
  for (int i = 0; i < n; i++) cin >> nn[i];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      cin >> mat[i][j];
    }
  for (int i = 0; i < m; i++) {
    if (mm[i]) {
      for (int j = 0; j < n; j++) {
        if (mat[j][i]) ans[j][i] = mm[i];
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (nn[i]) {
      for (int j = 0; j < m; j++) {
        if (mat[i][j]) {
          if (ans[i][j]) {
            if (ans[i][j] > nn[i]) ans[i][j] = nn[i];
          } else
            ans[i][j] = nn[i];
        }
      }
    }
  }
  cout << "\n";
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cout << ans[i][j] << " ";
    }
    cout << "\n";
  }
}
