#include <bits/stdc++.h>
using namespace std;
int N, M, K;
vector<int> V[6][200003], ach[200003];
vector<vector<vector<int> > > ans;
void input(vector<int> *V, int r, int c) {
  for (int i = 0; i <= r - 1; ++i) {
    V[i].resize(c);
    for (int j = 0; j <= c - 1; ++j) scanf("%d", &V[i][j]);
  }
}
int main() {
  freopen("in", "r", stdin);
  scanf("%d %d %d", &N, &M, &K);
  for (int j = 0; j <= M - 1; ++j) ach[j].resize(K);
  input(V[0], M, K);
  input(V[1], M, K);
  input(V[2], N, K);
  input(V[3], N, K);
  input(V[4], N, M);
  input(V[5], N, M);
  for (int i = 0; i <= M - 1; ++i)
    for (int j = 0; j <= K - 1; ++j)
      if (!V[0][i][j] ^ !V[1][i][j]) {
        puts("-1");
        return 0;
      }
  for (int i = 0; i <= N - 1; ++i)
    for (int j = 0; j <= K - 1; ++j)
      if (!V[2][i][j] ^ !V[3][i][j]) {
        puts("-1");
        return 0;
      }
  for (int i = 0; i <= N - 1; ++i)
    for (int j = 0; j <= M - 1; ++j)
      if (!V[4][i][j] ^ !V[5][i][j]) {
        puts("-1");
        return 0;
      }
  for (int i = 0; i <= N - 1; ++i) {
    vector<vector<int> > val(M, vector<int>(K, 0));
    if (i == N - 1)
      for (int j = 0; j <= M - 1; ++j)
        for (int k = 0; k <= K - 1; ++k)
          if (V[0][j][k] == -1)
            V[0][j][k] = V[1][j][k];
          else if (V[0][j][k] != V[1][j][k]) {
            puts("-1");
            return 0;
          }
    queue<pair<int, int> > q;
    vector<pair<int, int> > mdf;
    vector<int> golr[2], godu[2];
    golr[0] = vector<int>(K, -1);
    golr[1] = vector<int>(K, M);
    godu[0] = vector<int>(M, -1);
    godu[1] = vector<int>(M, K);
    for (int j = 0; j <= K - 1; ++j) {
      if (V[2][i][j])
        q.push(pair<int, int>(2, j));
      else
        golr[0][j] = M;
      if (V[3][i][j])
        q.push(pair<int, int>(3, j));
      else
        golr[1][j] = -1;
    }
    for (int j = 0; j <= M - 1; ++j) {
      if (V[4][i][j])
        q.push(pair<int, int>(4, j));
      else
        godu[0][j] = K;
      if (V[5][i][j])
        q.push(pair<int, int>(5, j));
      else
        godu[1][j] = -1;
    }
    while (!q.empty()) {
      pair<int, int> t = q.front();
      q.pop();
      int v = t.first, x = t.second;
      if (t.first <= 3) {
        int fl = v & 1 ? -1 : 1, &t = golr[v & 1][x];
        t += fl;
        while (golr[0][x] <= golr[1][x] && golr[0][x] < M && ~golr[1][x])
          if (!~V[0][t][x]) {
            mdf.push_back(pair<int, int>(t, x));
            V[0][t][x] = V[v][i][x];
            break;
          } else if (V[0][t][x] == V[v][i][x] && godu[0][t] <= x &&
                     godu[1][t] >= x)
            break;
          else {
            if (godu[0][t] == x) q.push(pair<int, int>(4, t));
            if (godu[1][t] == x) q.push(pair<int, int>(5, t));
            t += fl;
          }
        if (golr[0][x] > golr[1][x] || golr[0][x] == M || golr[1][x] == -1) {
          puts("-1");
          return 0;
        }
      } else {
        int fl = v & 1 ? -1 : 1, &t = godu[v & 1][x];
        t += fl;
        while (godu[0][x] <= godu[1][x] && godu[0][x] < K && godu[1][x] != -1)
          if (!~V[0][x][t]) {
            mdf.push_back(pair<int, int>(x, t));
            V[0][x][t] = V[v][i][x];
            break;
          } else if (V[0][x][t] == V[v][i][x] && golr[0][t] <= x &&
                     golr[1][t] >= x)
            break;
          else {
            if (golr[0][t] == x) q.push(pair<int, int>(2, t));
            if (golr[1][t] == x) q.push(pair<int, int>(3, t));
            t += fl;
          }
        if (godu[0][x] > godu[1][x] || godu[0][x] == K || godu[1][x] == -1) {
          puts("-1");
          return 0;
        }
      }
    }
    for (auto t : mdf) V[0][t.first][t.second] = -1;
    for (int j = 0; j <= K - 1; ++j)
      if (V[2][i][j]) {
        val[golr[0][j]][j] = V[2][i][j];
        val[golr[1][j]][j] = V[3][i][j];
      }
    for (int j = 0; j <= M - 1; ++j)
      if (V[3][i][j]) {
        val[j][godu[0][j]] = V[4][i][j];
        val[j][godu[1][j]] = V[5][i][j];
      }
    for (int j = 0; j <= M - 1; ++j)
      for (int k = 0; k <= K - 1; ++k) {
        if (!val[j][k] && golr[0][k] <= j && golr[1][k] >= j &&
            godu[0][j] <= k && godu[1][j] >= k) {
          val[j][k] = V[0][j][k] == -1 ? V[1][j][k] : V[0][j][k];
        }
        if (val[j][k]) {
          V[0][j][k] = -1;
          ach[j][k] = V[1][j][k] == val[j][k];
        } else if (i == N - 1 && !ach[j][k] && V[0][j][k]) {
          puts("-1");
          return 0;
        }
      }
    ans.push_back(val);
  }
  for (int i = 0; i <= N - 1; ++i) {
    for (int j = 0; j <= M - 1; ++j)
      for (int k = 0; k <= K - 1; ++k)
        printf("%d%c", ans[i][j][k], " \n"[k == K - 1]);
    puts("");
  }
  return 0;
}
