#include <bits/stdc++.h>
using namespace std;
const int sizes = 20 * 50000;
bitset<sizes> b[49][25];
using ll = long long;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  int *a = new int[2 * n];
  ll sum = 0;
  for (int i = 0; i < 2 * n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a, a + 2 * n);
  ll pilnas = a[0] + a[1];
  sum -= pilnas;
  a = a + 2;
  n--;
  b[0][0][0] = 1;
  for (int i = 0; i < 2 * n; i++) {
    for (int j = 0; j <= n; j++) {
      b[i + 1][j] |= b[i][j];
      if (j > 0) {
        b[i + 1][j] |= b[i][j - 1] << a[i];
      }
    }
  }
  ll ats;
  for (ats = sum / 2; !b[2 * n][n][ats]; ats--)
    ;
  vector<int> pirm;
  vector<int> antr;
  int j = n;
  for (int i = 2 * n; i > 0; i--) {
    if (j > 0 and ats >= a[i - 1] and b[i - 1][j - 1][ats - a[i - 1]]) {
      pirm.push_back(i - 1);
      ats -= a[i - 1];
      j--;
    } else {
      antr.push_back(i - 1);
    }
  }
  cout << a[-1] << " ";
  reverse(pirm.begin(), pirm.end());
  for (auto &&i : pirm) {
    cout << a[i] << " ";
  }
  cout << endl;
  for (auto &&i : antr) {
    cout << a[i] << " ";
  }
  cout << a[-2] << " ";
}
