Antipalindromic words

In this problem, we say that a word is antipalindromic if it does not
contain any subword that is a palindrome (with the exception of empty
subwords and single letters). Write a program that prints all the
antipalindromic words of length n that can be made up with the first x
lowercase letters.

Input

Input consists of n and x. Suppose 1 ≤ n ≤ 50 and 1 ≤ x ≤ 26.

Output

Print, in alphabetic order, all the antipalindromic words of length n
that can be made up with the first x lowercase letters.

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-01-25T12:18:58.372Z

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