#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const long long INF = std::numeric_limits<long long>::max();
const int MX = 100101;
const long double PI =
    3.14159265358979323846264338327950288419716939937510582097494L;
template <typename T>
pair<T, T> operator+(const pair<T, T> &a, const pair<T, T> &b) {
  return pair<T, T>(a.first + b.first, a.second + b.second);
}
template <typename T>
pair<T, T> operator-(const pair<T, T> &a, const pair<T, T> &b) {
  return pair<T, T>(a.first - b.first, a.second - b.second);
}
template <typename T>
T operator*(const pair<T, T> &a, const pair<T, T> &b) {
  return (a.first * b.first + a.second * b.second);
}
template <typename T>
T operator^(const pair<T, T> &a, const pair<T, T> &b) {
  return (a.first * b.second - a.second * b.first);
}
template <typename T>
void print(vector<T> vec, string name = "") {
  cout << name;
  for (auto u : vec) cout << u << ' ';
  cout << '\n';
}
vector<vector<vector<bool> > > dp(
    54, vector<vector<bool> >(26, vector<bool>(50000 * 26, false)));
vector<int> sk;
int N;
int sum;
vector<int> pirmas, antras;
int curr = MOD;
void get(int n, int pirmame, vector<int> &pir, vector<int> &ant) {
  if (dp[n][pir.size()][pirmame]) return;
  if (n == 2 * N) {
    if ((int)pir.size() == N - 1 and max(pirmame, sum - pirmame) < curr) {
      pirmas = pir;
      antras = ant;
      curr = max(pirmame, sum - pirmame);
    }
    return;
  }
  dp[n][pir.size()][pirmame] = true;
  if ((int)ant.size() + 1 < N) {
    ant.push_back(sk[n]);
    get(n + 1, pirmame, pir, ant);
    ant.pop_back();
  }
  if ((int)pir.size() + 1 < N) {
    pir.push_back(sk[n]);
    get(n + 1, pirmame + sk[n], pir, ant);
    pir.pop_back();
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> N;
  sk = vector<int>(2 * N);
  for (int i = 0; i < 2 * N; ++i) cin >> sk[i];
  sort(sk.begin(), sk.end());
  for (int i = 2; i < 2 * N; ++i) sum += sk[i];
  vector<int> piv, piv2;
  get(2, 0, piv, piv2);
  pirmas.push_back(sk[0]);
  antras.push_back(sk[1]);
  sort(pirmas.begin(), pirmas.end());
  sort(antras.rbegin(), antras.rend());
  print(pirmas);
  print(antras);
}
