Two rows of numbers

You have 2n2n different numbers. Write a program to find all the ways to put the numbers in two rows x1xnx_1 \dots x_n and y1yny_1 \dots y_n so that:

Input

Input consists of nn, followed by 2n2n different integer numbers. Assume 1n111 \le n \le 11.

Output

Print all the ways to put the numbers fulfilling the required conditions. For every way, print three lines: two rows with xix_i and yiy_i separated by spaces, and an empty line. Print the solutions in lexicographical order: first, those with the smaller x1x_1, in case of a tie, those with the smaller x2x_2, …, in case of a tie, those with the smaller xnx_n, in case of a tie, those with the smaller y1y_1, …

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-01-25T12:00:39.323Z

© Jutge.org, 2006–2026.
https://jutge.org