#include <bits/stdc++.h>
using namespace std;
const int N = 26, M = 5e4 + 100;
int n, sum, a[N << 1], ans[2][N];
bitset<N * M> dp[N][N];
bitset<N * M> bk[N][N];
void input() {
  cin >> n;
  for (int i = 0; i < (n << 1); i++) cin >> a[i];
  sort(a, a + 2 * n);
  ans[0][0] = a[0];
  ans[1][n - 1] = a[1];
  for (int i = 1; i <= 2 * n - 2; i++) sum += (a[i] = a[i + 1]);
}
void solve() {
  dp[0][0][0] = true;
  for (int i = 0; i <= n - 1; i++)
    for (int j = (i ? 0 : 1); j <= n - 1 && i + j <= 2 * (n - 1); j++)
      for (int k = 0; k < N * M; k++) {
        if (i && k >= a[i + j] && dp[i - 1][j][k - a[i + j]]) {
          dp[i][j][k] = true;
          bk[i][j][k] = 0;
        } else if (j && dp[i][j - 1][k]) {
          dp[i][j][k] = true;
          bk[i][j][k] = 1;
        }
      }
}
void output() {
  int x = N * M;
  for (int i = sum; 2 * i >= sum; i--)
    if (dp[n - 1][n - 1][i]) x = i;
  int rem = n - 1;
  for (int i = 2 * (n - 1); i; i--)
    if (bk[rem][i - rem][x] == 0) {
      ans[0][rem--] = a[i];
      x -= a[i];
    } else
      ans[1][n - i + rem - 1] = a[i];
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < n; j++) cout << ans[i][j] << " \n"[j == n - 1];
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  input();
  solve();
  output();
  return 0;
}
