わかさぎのブログ

プログラミング、Atcoderの勉強とか

AtCoder Beginner Contest 068 Cat Snuke and a Voyage

N,M=map(int,input().split())
ab=[]
for i in range(M):
    tmp=list(map(int,input().split()))
    ab.append(tmp)


from collections import defaultdict

graph=defaultdict(list)

for i in range(M):
    l=ab[i][0]
    r=ab[i][1]
    graph[l].append(r)
    graph[r].append(l)

S=set()

for i in graph[1]:
    S.add(i)
    for j in graph[i]:
        S.add(j)

print("POSSIBLE") if N in S else print("IMPOSSIBLE")