Consider a word
of length
,
with only letters ‘a’ and ‘b’. For any prefix
of
,
let
be the number of ‘a’ within
,
and let
be the number of ‘b’ within
.
In this problem, we say that
is compensated if and only if for every of the
prefixes
of
we have
.
For instance, “abbaaabb” is compensated, but
“abbaaaab” is not, because “abbaaaa” is a
prefix with five ‘a’ and two ‘b’. As other
examples, neither “bbb” nor “bbbbbb” are
compensated.
Given an , print all compensated words of this length.
Input consists of an between 1 and 18.
Print in alphabetical order all compensated words with
characters chosen between ‘a’ and ‘b’.
Input
1
Output
a b
Input
4
Output
aaba aabb abaa abab abba abbb baaa baab baba babb bbaa bbab