You are on page 1of 1

The 2023 ICPC Programming Contest

University of Science, VNU-HCM


October 01, 2023

Problem H
Palindrome Mooncake Sequence
Time Limit: 1 second
Memory Limit: 256 megabytes
In preparation for the upcoming Mid-Autumn Festival, a bakery is
planning to offer a special selection of mooncakes:
• Almond Filling Mooncake (A): This mooncake is filled with rich,
creamy almond paste. It has a sweet and nutty flavor that is loved
by many.
• Taro and Yam Mooncake (T): This mooncake is filled with a
delightful mixture of taro and yam, creating a creamy and slightly
sweet filling. It's a unique and delicious option for those who appreciate root vegetable
flavors.
• Chocolate Ganache Mooncake (C): This mooncake is filled with a luscious chocolate
ganache, giving it a decadent and indulgent taste. It's perfect for chocolate lovers.
• Green Tea Matcha Mooncake (G): This mooncake features a green tea matcha filling,
which is both aromatic and slightly bitter, balanced by a sweet outer pastry crust. It's a
favorite among those who enjoy green tea flavors.
Each mooncake type has its lovely color: creamy white (A), lavender (T), dark brown (C), and
vibrant green (G).
The bakery intends to display n mooncakes in a sequence, where n is a positive integer. There
is no restriction on the number of each mooncake type in the display of the bakery. The bakery
wants to make the sequence of mooncakes in the display to be a palindrome. A palindrome is a
string that reads the same forwards and backwards. For example: "A", "TAT", "ACTTGTTCA"
are palindrome patterns, and "AT", "ACAC" are not palindrome.
All palindrome mooncake sequences are sorted ascendingly in dictionary (lexicographic) order.
Please help the bakery select the 𝑘 𝑡ℎ mooncake sequence, or simply report “Impossible” if there
is no such mooncake sequence.
Input
A single line containing two integers 𝑛 (1 ≤ 𝑛 ≤ 100) and 𝑘 (for 1 ≤ 𝑘 ≤ 1018 ) separated by
a space.

Output
A single string the 𝑘 𝑡ℎ mooncake sequence or "Impossible" (without quotation marks) if
the 𝑘 𝑡ℎ sequence does not exist.

Sample Input Sample Output


5 6 ACCCA
10

You might also like