문제1852--Colored Sticks

1852: Colored Sticks

실행시간 제한: 5 Sec  메모리사용 제한: 125 MB
제출: 88  통과: 19
[제출] [채점기록] [묻고답하기]

문제 설명

You are given a bunch of wooden sticks. Each endpoint of each stick is colored with some color. Is it possible to align the sticks in a straight line such that the colors of the endpoints that touch are of the same color?

입력 설명

Input is a sequence of lines, each line contains two words, separated by spaces, giving the colors of the endpoints of one stick. A word is a sequence of lowercase letters no longer than 10 characters. There is no more than 250000 sticks.

출력 설명

If the sticks can be aligned in the desired way, output a single line saying Possible, otherwise output Impossible.

입력 예시 Copy

blue red
red violet
cyan blue
blue magenta
magenta cyan

출력 예시 Copy

Possible

출처/분류