#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  bool flag = false;
  while (!isdigit(c)) {
    if (c == '-') flag = true;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  if (flag) x = -x;
}
int n, sum, cnt;
long long sta;
int ans[2][55], v[55];
long long f[27][1300010];
int main() {
  read(n);
  for (int i = 1; i <= 2 * n; ++i) read(v[i]), sum += v[i];
  sort(v + 1, v + 2 * n + 1), sum = (sum - v[1] - v[2]) / 2;
  memset(f, -1, sizeof(f)), f[0][0] = 0;
  for (int i = 3; i <= 2 * n; ++i)
    for (int j = min(i - 2, n - 1); j; --j)
      for (int k = sum; k >= v[i]; --k)
        if (~f[j - 1][k - v[i]])
          f[j][k] = f[j - 1][k - v[i]] | ((long long)1 << i);
  while (f[n - 1][sum] == -1) sum--;
  sta = f[n - 1][sum], ans[0][cnt = 1] = v[1];
  for (int i = 3; i <= 2 * n; ++i)
    if (sta & ((long long)1 << i)) ans[0][++cnt] = v[i];
  ans[1][cnt = n] = v[2];
  for (int i = 3; i <= 2 * n; ++i)
    if (!(sta & ((long long)1 << i))) ans[1][--cnt] = v[i];
  for (int i = 0; i <= 1; ++i)
    for (int j = 1; j <= n; ++j) printf("%d%c", ans[i][j], " \n"[j == n]);
  return 0;
}
