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;
const long long MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
int n, tar, mini = INF, minb;
int arr[60], brr[30];
char pcnt[17000000];
vector<int> lis[27];
map<int, int> lo;
int num[27];
void calc(int arr[]) {
  vector<int> sum(17000000, 0);
  for (int i = 1, c = 0; c < n; i *= 2, c++) {
    lo[i] = c;
  }
  for (int i = 0; i < (1 << (n - 1)); i++) {
    num[pcnt[i]]++;
  }
  for (int i = 0; i < n - 1; i++) {
    lis[i].reserve(num[i] + 2);
  }
  lis[0].push_back(0);
  for (int i = 1; i < (1 << (n - 1)); i++) {
    sum[i] = sum[i & (i - 1)] + arr[lo[i & -i]];
    lis[pcnt[i]].push_back(sum[i]);
  }
  vector<int>().swap(sum);
}
void calc2(int arr[]) {
  vector<int> sum(17000000, 0);
  for (int i = 1; i < (1 << (n - 1)); i++) {
    sum[i] = sum[i & (i - 1)] + arr[lo[i & -i]];
    int t = n - 1 - pcnt[i];
    int p = upper_bound(lis[t].begin(), lis[t].end(), tar / 2 - sum[i]) -
            lis[t].begin();
    if (p < lis[t].size()) {
      if (mini > abs(2 * (sum[i] + lis[t][p]) - tar)) {
        mini = abs(2 * (sum[i] + lis[t][p]) - tar);
        minb = i;
      }
    }
    p--;
    if (p >= 0) {
      if (mini > abs(2 * (sum[i] + lis[t][p]) - tar)) {
        mini = abs(2 * (sum[i] + lis[t][p]) - tar);
        minb = i;
      }
    }
  }
  vector<int>().swap(sum);
}
pair<int, int> calc3(int arr[]) {
  int sum = 0;
  for (int i = 0; i < n - 1; i++) {
    if (minb >> i & 1) {
      sum += arr[i];
    }
  }
  int t = n - 1 - pcnt[minb];
  int p =
      upper_bound(lis[t].begin(), lis[t].end(), tar / 2 - sum) - lis[t].begin();
  if (p < lis[t].size()) {
    if (mini == abs(2 * (sum + lis[t][p]) - tar)) {
      return {t, lis[t][p]};
    }
  }
  p--;
  if (p >= 0) {
    if (mini == abs(2 * (sum + lis[t][p]) - tar)) {
      return {t, lis[t][p]};
    }
  }
}
int calc4(int arr[], int t, int p) {
  vector<int> sum(17000000, 0);
  if (t == 0) return 0;
  for (int i = 1; i < (1 << (n - 1)); i++) {
    sum[i] = sum[i & (i - 1)] + arr[lo[i & -i]];
    if (pcnt[i] == t && sum[i] == p) {
      return i;
    }
  }
  vector<int>().swap(sum);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n * 2; i++) scanf("%d", &arr[i]);
  pcnt[0] = 0;
  for (int i = 1; i < (1 << (n - 1)); i++) pcnt[i] = pcnt[i & (i - 1)] + 1;
  sort(arr, arr + 2 * n);
  int t0 = arr[0], t1 = arr[1];
  for (int i = 0; i < 2 * n - 2; i++) arr[i] = arr[i + 2];
  for (int i = 0; i < 2 * n - 2; i++) tar += arr[i];
  for (int i = 0; i < n - 1; i++) brr[i] = arr[i + n - 1];
  calc(arr);
  calc2(brr);
  pair<int, int> tmp = calc3(brr);
  int minb2 = calc4(arr, tmp.first, tmp.second);
  vector<int> ans, ans2;
  for (int i = 0; i < n - 1; i++) {
    if (minb2 >> i & 1)
      ans.push_back(arr[i]);
    else
      ans2.push_back(arr[i]);
    if (minb >> i & 1)
      ans.push_back(brr[i]);
    else
      ans2.push_back(brr[i]);
  }
  sort(ans.begin(), ans.end());
  sort(ans2.begin(), ans2.end());
  printf("%d ", t0);
  for (int i = 0; i < n - 1; i++) printf("%d ", ans[i]);
  printf("\n");
  for (int i = n - 2; i >= 0; i--) printf("%d ", ans2[i]);
  printf("%d\n", t1);
  return 0;
}