#include <bits/stdc++.h>
using namespace std;
bool vis1[101], vis2[101];
int main() {
  int n, m, h, g[101][101], a[101], b[101];
  cin >> n >> m >> h;
  for (int i = 0; i < m; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> g[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (g[i][j] == 1 && a[j] == b[i]) {
        g[i][j] = a[j];
      } else if (g[i][j] && b[i] > a[j])
        g[i][j] = a[j];
      else if (g[i][j] && b[i] < a[j])
        g[i][j] = b[i];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (g[i][j] == -1) g[i][j] = 1;
      cout << g[i][j] << " ";
    }
    cout << endl;
  }
}
