406027: GYM102219 J Kitchen Plates
Description
You are given 5 different sizes of kitchen plates. Each plate is marked with a letter $$$A$$$, $$$B$$$, $$$C$$$, $$$D$$$, or $$$E$$$. You are given 5 statements comparing two different plates, you need to rearrange the plates from smallest size to biggest size. For example: the sizes of these plates.
The input consist of 5 lines. In each line there will be 3 characters, the first and last character will be either $$$A$$$, $$$B$$$, $$$C$$$, $$$D$$$, or $$$E$$$ and the middle character will be either $$$>$$$ or $$$<$$$ describing the comparison between two plates sizes. No two plates will be equal.
OutputThe output consist of $$$5$$$ characters, the sorted order of balls from smallest to biggest plate. Otherwise, if the statements are contradicting print $$$impossible$$$. If there are multiple answers, print any of them.
ExamplesInputD>B A>D E<C A>B B>COutput
ECBDAInput
B>E A>B E>A C<B D<BOutput
impossible