#include <bits/stdc++.h>
using namespace std;
const int N = 1250000;
bitset<N> f[51][26];
int r[51];
int a[51];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n + n; ++i) cin >> a[i];
  sort(a + 1, a + 1 + n + n);
  r[2] = 1;
  for (int i = 2; i <= n + n; ++i) {
    f[i][0] = 1;
    for (int j = 1; j <= n; ++j)
      f[i][j] = (f[i - 1][j] | (f[i - 1][j - 1] << a[i]));
  }
  int Sum = 0;
  for (int i = 3; i <= n + n; ++i) Sum += a[i];
  for (int i = Sum / 2; i; --i)
    if (f[n + n][n - 1][i]) {
      Sum = i;
      break;
    }
  for (int i = n + n, e = n - 1; i && e; --i)
    if (Sum >= a[i] && f[i - 1][e - 1][Sum - a[i]]) {
      Sum -= a[i];
      r[i] = 1;
      e--;
    }
  for (int i = 1; i <= n + n; ++i)
    if (r[i] == 0) cout << a[i] << " ";
  cout << "\n";
  for (int i = n + n; i >= 1; --i)
    if (r[i] == 1) cout << a[i] << " ";
  cout << "\n";
}
