#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
vector<int> V1;
vector<vector<int>> V2;
vector<vector<pair<int, int>>> V3;
vector<vector<vector<pair<int, int>>>> V4;
vector<pair<int, int>> V5;
vector<vector<vector<vector<pair<int, int>>>>> a;
bool add(int x, int y, int z, pair<int, int> p) {
  for (int i = 0; i < a[x][y][z].size(); i++) {
    pair<int, int> q = a[x][y][z][i];
    if ((q.first ^ p.first) == 1) {
      a[x][y][z][i].first = 6;
      if (q.second == INF) {
        if (p.second == 0) return false;
        a[x][y][z][i].second = p.second;
        return true;
      } else if (q.second == 0) {
        if (p.second == 0)
          return true;
        else
          return false;
      } else {
        if (p.second == 0)
          return false;
        else if (p.second == INF)
          return true;
        else
          return p.second == q.second;
      }
    }
  }
  a[x][y][z].push_back(p);
  return true;
}
int main() {
  static int n, m, k;
  static vector<vector<vector<int>>> ret;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; i++) {
    ret.push_back(V2);
    a.push_back(V4);
    for (int j = 0; j < m; j++) {
      ret[i].push_back(V1);
      a[i].push_back(V3);
      for (int t = 0; t < k; t++) {
        ret[i][j].push_back(-1);
        a[i][j].push_back(V5);
      }
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < k; j++) {
      int x;
      scanf("%d", &x);
      if (!add(0, i, j, pair<int, int>(0, x))) {
        puts("-1");
        return 0;
      }
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < k; j++) {
      int x;
      scanf("%d", &x);
      if (!add(n - 1, i, j, pair<int, int>(1, x))) {
        puts("-1");
        return 0;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < k; j++) {
      int x;
      scanf("%d", &x);
      if (!add(i, 0, j, pair<int, int>(2, x))) {
        puts("-1");
        return 0;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < k; j++) {
      int x;
      scanf("%d", &x);
      if (!add(i, m - 1, j, pair<int, int>(3, x))) {
        puts("-1");
        return 0;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int x;
      scanf("%d", &x);
      if (!add(i, j, 0, pair<int, int>(4, x))) {
        puts("-1");
        return 0;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int x;
      scanf("%d", &x);
      if (!add(i, j, k - 1, pair<int, int>(5, x))) {
        puts("-1");
        return 0;
      }
    }
  }
  map<pair<int, pair<int, int>>, int> cnt;
  queue<pair<int, pair<int, int>>> que;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      for (int t = 0; t < k; t++) {
        if (a[i][j][t].size() >= 3)
          que.push(pair<int, pair<int, int>>(i, pair<int, int>(j, t)));
      }
    }
  }
  while (!que.empty()) {
    pair<int, pair<int, int>> p = que.front();
    que.pop();
    int x = p.first;
    int y = p.second.first;
    int z = p.second.second;
    if (ret[x][y][z] != -1) continue;
    ret[x][y][z] = INF;
    int color = INF;
    for (pair<int, int> q : a[x][y][z]) {
      if (q.second == INF) continue;
      if (q.first == 6) {
        color = q.second;
        break;
      } else {
        if (color == INF)
          color = q.second;
        else if (color != q.second)
          color = 0;
      }
    }
    for (pair<int, int> q : a[x][y][z]) {
      if (q.second == INF) continue;
      if (q.first == 6) {
        if (q.second != color) {
          puts("-1");
          return 0;
        }
      } else {
        if (color != INF && color != 0 && color != q.second) {
          puts("-1");
          return 0;
        }
      }
    }
    ret[x][y][z] = color;
    if (color == INF) ret[x][y][z] = 0;
    if (color != 0) {
      for (pair<int, int> q : a[x][y][z]) {
        if (q.first == 6) continue;
        if (q.second == INF) continue;
        if (q.first <= 1) {
          cnt[pair<int, pair<int, int>>(-1, pair<int, int>(y, z))]++;
          if (cnt[pair<int, pair<int, int>>(-1, pair<int, int>(y, z))] == 2) {
            for (int nx = 0; nx < n; nx++) {
              if (!add(nx, y, z, pair<int, int>(q.first, INF))) {
                puts("-1");
                return 0;
              }
              if (a[nx][y][z].size() >= 3)
                que.push(pair<int, pair<int, int>>(nx, pair<int, int>(y, z)));
            }
          }
        } else if (q.first <= 3) {
          cnt[pair<int, pair<int, int>>(x, pair<int, int>(-1, z))]++;
          if (cnt[pair<int, pair<int, int>>(x, pair<int, int>(-1, z))] == 2) {
            for (int ny = 0; ny < m; ny++) {
              if (!add(x, ny, z, pair<int, int>(q.first, INF))) {
                puts("-1");
                return 0;
              }
              if (a[x][ny][z].size() >= 3)
                que.push(pair<int, pair<int, int>>(x, pair<int, int>(ny, z)));
            }
          }
        } else {
          cnt[pair<int, pair<int, int>>(x, pair<int, int>(y, -1))]++;
          if (cnt[pair<int, pair<int, int>>(x, pair<int, int>(y, -1))] == 2) {
            for (int nz = 0; nz < k; nz++) {
              if (!add(x, y, nz, pair<int, int>(q.first, INF))) {
                puts("-1");
                return 0;
              }
              if (a[x][y][nz].size() >= 3)
                que.push(pair<int, pair<int, int>>(x, pair<int, int>(y, nz)));
            }
          }
        }
      }
    } else {
      for (pair<int, int> q : a[x][y][z]) {
        if (q.first == 6) continue;
        if (q.second == INF) continue;
        int nx = x, ny = y, nz = z;
        if (q.first == 0)
          nx++;
        else if (q.first == 1)
          nx--;
        else if (q.first == 2)
          ny++;
        else if (q.first == 3)
          ny--;
        else if (q.first == 4)
          nz++;
        else if (q.first == 5)
          nz--;
        if (!add(nx, ny, nz, q)) {
          puts("-1");
          return 0;
        }
        if (a[nx][ny][nz].size() >= 3)
          que.push(pair<int, pair<int, int>>(nx, pair<int, int>(ny, nz)));
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      for (int t = 0; t < k; t++) {
        cout << ret[i][j][t] << " ";
      }
    }
  }
}
