Forbidden words

Write a program that, given a number nn, prints all the words that are a permutation of the first nn lowercase letters, with one restriction: there cannot be two letters xx and yy such that yy is immediately to the right of xx in the word and yy is the letter following xx in the alphabet.

Input

Input consists of a natural number nn between 1 and 9.

Output

Print in order and one per line all the words that satisfy the restriction.

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-01-25T12:19:18.851Z

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