#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int main() {
  int n, m, h;
  cin >> n >> m >> h;
  vector<int> sc(m, 0);
  for (int(i) = 0; (i) < (m); (i)++) cin >> sc[i];
  vector<int> sr(n, 0);
  for (int(i) = 0; (i) < (n); (i)++) cin >> sr[i];
  int st[100][100];
  for (int(i) = 0; (i) < (n); (i)++)
    for (int(j) = 0; (j) < (m); (j)++) cin >> st[i][j];
  int ans[100][100];
  for (int(i) = 0; (i) < (n); (i)++)
    for (int(j) = 0; (j) < (m); (j)++) ans[i][j] = 0;
  for (int(i) = 0; (i) < (n); (i)++)
    for (int(j) = 0; (j) < (m); (j)++) {
      if (st[i][j]) ans[i][j] = min(sc[j], sr[i]);
    }
  for (int(i) = 0; (i) < (n); (i)++) {
    for (int(j) = 0; (j) < (m); (j)++) {
      cout << ans[i][j] << " ";
    }
    cout << endl;
  }
}
