No wells

A sequence of numbers has a well if it contains three consecutive numbers such that the endpoints add up more than twice the one in the middle. Formally, (x1,x2,,xn)(x_1, x_2, \dots, x_n) has a well if it exists at least an ii with 2in12 \le i \le n - 1 such that xi1+xi+1>2xix_ {i-1} + x_{i+1} > 2 x_i.

Write a program that, given an integer nn, prints all the sequences with no wells that can be obtained by reordering the sequence (1,2,,n)(1, 2, \dots, n).

Input

Input consists of several cases, each one with an nn between 1 and 10510^5.

Output

For every nn, print all the permutations with no wells in lexicographical order. Print a line with 10 dashes at the end of every case.

Problem information

Author: Albert Oliveras

Generation: 2026-01-25T11:13:59.192Z

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