#B3690. Custom Alphabet Ordering
Custom Alphabet Ordering
Custom Alphabet Ordering
Aya has two teaching assistants with nicknames: "某 E" and "L 队". Using a special weapon, he obtained their real names as two strings \(s\) and \(t\), each consisting of only lowercase English letters. Aya believes that a person's strength is related to the lexicographical order of their name — a name that comes earlier means a stronger person. However, in reality, L 队 is strictly stronger than 某 E, which means under the correct redefined order, \(t < s\).
Your task is to redefine the order of the 26 lowercase letters so that when comparing the strings \(s\) and \(t\) using the new lexicographical order, the condition \(t < s\) holds. The lexicographical comparison is defined as follows:
- Either \(t\) is a prefix of \(s\), or
- There exists an index \(j \leq \min(|s|,|t|)\) such that for all \(1 \leq i < j\), \(s_i = t_i\) and \(t_j < s_j\) (where the comparison \(<\) is based on your redefined order).
inputFormat
The input consists of two lines. The first line contains the string \(s\) and the second line contains the string \(t\). Both strings consist only of lowercase English letters.
outputFormat
If a valid ordering exists, output any permutation of the 26 lowercase letters that satisfies \(t < s\) when \(s\) and \(t\) are compared lexicographically according to your new order. Otherwise, output Impossible
.
sample
abc
abd
dbacefghijklmnopqrstuvwxyz
</p>