Problem: Kolya has a turtle and a field of size 2 × n. The field rows are numbered from 1 to 2 from top to bottom, while the columns are numbered from 1 to n from left to right.

Suppose in each cell of the field there is a lettuce leaf. The energy value of lettuce leaf in row i and column j is equal to a_{i,j}. The turtle is initially in the top left cell and wants to reach the bottom right cell. The turtle can only move right and down and among all possible ways it will choose a way, maximizing the total energy value of lettuce leaves (in case there are several such paths, it will choose any of them).

Kolya is afraid, that if turtle will eat too much lettuce, it can be bad for its health. So he wants to reorder lettuce leaves in the field, so that the energetic cost of leaves eaten by turtle will be minimized.

Input

The first line contains an integer n (2 ≤ n ≤ 25) — the length of the field.

The second line contains n integers a_{1, i} (0 ≤ a_{1, i} ≤ 50 000), the energetic cost of lettuce leaves in the first row of the field.

The third line contains n integers a_{2, i} (0 ≤ a_{2, i} ≤ 50 000), the energetic cost of lettuce leaves in the second row of the field.

Output

Print two lines with n integers in each — the optimal reordering of lettuce from the input data.

In case there are several optimal ways to reorder lettuce, print any of them.

Examples

Input


2
1 4
2 3


Output


1 3 
4 2 


Input


3
0 0 0
0 0 0


Output


0 0 0 
0 0 0 


Input


3
1 0 1
0 0 0


Output


0 0 1
0 1 0

Note

In the first example, after reordering, the turtle will eat lettuce with total energetic cost 1+4+2 = 7.

In the second example, the turtle will eat lettuce with energetic cost equal 0.

In the third example, after reordering, the turtle will eat lettuce with total energetic cost equal 1.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
long long INF = 1LL << 60;
long long MOD = 1e9 + 7;
template <typename A, typename B>
istream &operator>>(istream &is, pair<A, B> &pr) {
  is >> pr.first >> pr.second;
  return is;
}
template <typename A>
istream &operator>>(istream &is, vector<A> &v) {
  for (auto &x : v) is >> x;
  return is;
}
ostream &operator<<(ostream &os, char &c) {
  os << (char)c;
  return os;
}
ostream &operator<<(ostream &os, const char s[]) {
  os << (string)s;
  return os;
}
ostream &operator<<(ostream &os, string &s) {
  for (char &c : s) os << (char)c;
  return os;
}
template <typename A, typename B>
ostream &operator<<(ostream &os, pair<A, B> &pr) {
  os << '(' << pr.first << ", " << pr.second << ')';
  return os;
}
ostream &operator<<(ostream &os, vector<bool> &v) {
  bool first = true;
  os << '[';
  for (const bool &x : v) {
    if (!first) os << ", ";
    first = false;
    os << x;
  }
  os << ']';
  return os;
}
template <class C>
ostream &operator<<(ostream &os, C &v) {
  bool first = true;
  os << '[';
  for (auto &x : v) {
    if (!first) os << ", ";
    first = false;
    os << x;
  }
  os << ']';
  return os;
}
int powa(int base, int exp) {
  int res = 1;
  while (exp) {
    if (exp & 1) res = res * base % MOD;
    base = base * base % MOD;
    exp >>= 1;
  }
  return res;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(2 * n);
  cin >> a;
  sort(a.rbegin(), a.rend());
  vector<int> log(1 << n);
  for (int i = (2); i < (1 << n); ++i) log[i] = 1 + log[i / 2];
  int mnA = a.back();
  a.pop_back();
  int mnB = a.back();
  a.pop_back();
  --n;
  const int BIG = 24 * 50000 + 1;
  vector<vector<int> > lft(n + 1, vector<int>(BIG, -1)),
      rgt(n + 1, vector<int>(BIG, -1));
  vector<int> dpsum(1 << n);
  lft[0][0] = rgt[0][0] = 0;
  for (int mask = (1); mask < (1 << n); ++mask) {
    dpsum[mask] = a[log[mask]] + dpsum[mask - (1 << log[mask])];
    lft[__builtin_popcountll(mask)][dpsum[mask]] = mask;
  }
  dpsum.assign(1 << n, 0);
  for (int mask = (1); mask < (1 << n); ++mask) {
    dpsum[mask] = a[n + log[mask]] + dpsum[mask - (1 << log[mask])];
    rgt[__builtin_popcountll(mask)][dpsum[mask]] = mask;
  }
  int sum = accumulate(a.begin(), a.end(), 0LL);
  int halfsum = sum / 2;
  int res = -1;
  int maskA, maskB;
  for (int sz = (0); sz < (n + 1); ++sz) {
    vector<int> vecA, vecB;
    for (int i = (0); i < (BIG); ++i)
      if (lft[sz][i] != -1) vecA.push_back(i);
    for (int i = (0); i < (BIG); ++i)
      if (rgt[n - sz][i] != -1) vecB.push_back(i);
    int i = 0;
    int j = vecB.size() - 1;
    while (i < vecA.size() && j >= 0) {
      if (vecA[i] + vecB[j] > halfsum)
        --j;
      else {
        if (vecA[i] + vecB[j] > res) {
          res = vecA[i] + vecB[j];
          maskA = lft[sz][vecA[i]];
          maskB = rgt[n - sz][vecB[j]];
        }
        res = max(res, vecA[i] + vecB[j]);
        ++i;
      }
    }
  }
  vector<int> top = {mnA};
  vector<int> bottom;
  for (int i = (0); i < (n); ++i) {
    if (maskA >> i & 1LL)
      top.push_back(a[i]);
    else
      bottom.push_back(a[i]);
  }
  for (int i = (0); i < (n); ++i) {
    if (maskB >> i & 1LL)
      top.push_back(a[n + i]);
    else
      bottom.push_back(a[n + i]);
  }
  bottom.push_back(mnB);
  sort(top.begin(), top.end());
  sort(bottom.rbegin(), bottom.rend());
  for (int i = (0); i < (n + 1); ++i) cout << top[i] << ' ';
  cout << '\n';
  for (int i = (0); i < (n + 1); ++i) cout << bottom[i] << ' ';
}