The alphabetical sum of an alphabetic string is defined as the sum of the indices of each character in the alphabet. For example, the alphabetical value of the string abce
is a
, b
, c
, and e
are
Steven has a string which consists strictly of lowercase letters and asterisks. The asterisks can each be replaced with any lowercase letter in the English alphabet.
Given an integer
Definition: A string
Input Specification
The input consists of two lines. The first line contains
The following table shows how the available 15 marks are distributed.
Mark Awarded | Expected Alphabetical Value | Length of Steven's String |
---|---|---|
Output Specification
If it is impossible to construct a string that satisfies Tommy's expectations, output Impossible
.
Otherwise, output the lexicographically smallest string such that the alphabetical sum of the string is
Sample Input 1
2
a*
Output for Sample Input 1
aa
Explanation of Output for Sample Input 1
The alphabetical sum of aa
is aa
is the only possible string in this case.
Sample Input 2
4
a**
Output for Sample Input 2
aab
Explanation of Output for Sample Input 2
The alphabetical value of aab
is aba
also have aab
is the lexicographically smallest.
Sample Input 3
1
a*
Output for Sample Input 3
Impossible
Explanation of Output for Sample Input 3
It can be shown that we cannot construct a string for this case that has an alphabetical sum of
Comments