#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
const int maxn = 105;
int zheng[maxn];
int ce[maxn];
int fu[maxn][maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m, h;
  cin >> n >> m >> h;
  memset(zheng, 0, sizeof(zheng));
  memset(ce, 0, sizeof(ce));
  memset(fu, 0, sizeof(fu));
  for (int i = 1; i <= m; i++) cin >> zheng[i];
  for (int i = 1; i <= n; i++) cin >> ce[i];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> fu[i][j];
      if (fu[i][j] == 0) continue;
      if (zheng[j] <= ce[i])
        fu[i][j] = zheng[j];
      else
        fu[i][j] = ce[i];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cout << fu[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}
