Time limit
2s
Memory limit
128 MB
You are given wooden sticks whose two ends are colored. Determine whether all sticks can be arranged in one straight line so that whenever two stick ends touch, the colors on those two ends are the same. Every stick must be used exactly once.
Input is given until EOF. Each line contains two lowercase English words separated by one space; they are the colors on the two ends of one stick. Each color name has length at most 10. The number of sticks is at most 250,000.
Print Possible if all sticks can be arranged in one valid line. Otherwise, print Impossible.