#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e2 + 1;
int a[maxn], b[maxn], t[maxn][maxn], n, m, h;
int main() {
  cin >> n >> m >> h;
  for (int i = 1; i <= m; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> t[i][j];
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++)
      if (a[i] <= b[j] && t[j][i]) {
        t[j][i] = a[i];
        break;
      }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++)
      if (b[i] <= a[j] && t[i][j] == 1) {
        t[i][j] = b[i];
        break;
      }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) cout << t[i][j] << " ";
    cout << endl;
  }
  return 0;
}
