import heapq

INFTY = 1e6

N,M = list(map(int,input().split()))

G = {}

for _ in range(M):

    a,b = list(map(int,input().split()))

    if a not in G:

        G[a] = []

    G[a].append(b)

    if b not in G:

        G[b] = []

    G[b].append(a)

d = [INFTY for _ in range(N+1)]

hist = [0 for _ in range(N+1)]

heap = [(0,1)]

d[1] = 0

while heap:

    cur = heapq.heappop(heap)

    hist[cur[1]] = 1

    for x in G[cur[1]]:

        if hist[x]==0:

            if d[x]>cur[0]+1:

                d[x] = cur[0]+1

                heapq.heappush(heap,(d[x],x))

if d[N]==2:

    print("POSSIBLE")

else:

    print("IMPOSSIBLE")
import heapq

INFTY = 10**6

N,M = list(map(int,input().split()))

G = {i:[] for i in range(1,N+1)}

for _ in range(M):

    a,b = list(map(int,input().split()))

    G[a].append(b)

    G[b].append(a)

dist = [INFTY for _ in range(N+1)]

hist = [0 for _ in range(N+1)]

heap = [(0,1)]

dist[1] = 0

hist[1] = 1

while heap:

    d,x = heapq.heappop(heap)

    if dist[x]<d:continue

    hist[x]=1

    for y in G[x]:

        if hist[y]==0 and dist[y]>d+1:

            dist[y] = d+1

            heapq.heappush(heap,(d+1,y))

if dist[N]==2:

    print("POSSIBLE")

else:

    print("IMPOSSIBLE")
import heapq

INFTY = 1e6
N, M = list(map(int, input().split()))
G = {}
for _ in range(M):
    a, b = list(map(int, input().split()))
    if a not in G:
        G[a] = []
    G[a].append(b)
    if b not in G:
        G[b] = []
    G[b].append(a)
d = [INFTY for _ in range(N + 1)]
hist = [0 for _ in range(N + 1)]
heap = [(0, 1)]
d[1] = 0
while heap:
    cur = heapq.heappop(heap)
    hist[cur[1]] = 1
    for x in G[cur[1]]:
        if hist[x] == 0:
            if d[x] > cur[0] + 1:
                d[x] = cur[0] + 1
                heapq.heappush(heap, (d[x], x))
if d[N] == 2:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

import heapq

INFTY = 10**6
N, M = list(map(int, input().split()))
G = {i: [] for i in range(1, N + 1)}
for _ in range(M):
    a, b = list(map(int, input().split()))
    G[a].append(b)
    G[b].append(a)
dist = [INFTY for _ in range(N + 1)]
hist = [0 for _ in range(N + 1)]
heap = [(0, 1)]
dist[1] = 0
hist[1] = 1
while heap:
    d, x = heapq.heappop(heap)
    if dist[x] < d:
        continue
    hist[x] = 1
    for y in G[x]:
        if hist[y] == 0 and dist[y] > d + 1:
            dist[y] = d + 1
            heapq.heappush(heap, (d + 1, y))
if dist[N] == 2:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

-INFTY = 1e6 +INFTY = 10**6 -G = {} +G = {i: [] for i in range(1, N + 1)} -    if a not in G: -        G[a] = [] -    if b not in G: -        G[b] = [] -d = [INFTY for _ in range(N + 1)] +dist = [INFTY for _ in range(N + 1)] -d[1] = 0 +dist[1] = 0 +hist[1] = 1 -    cur = heapq.heappop(heap) -    hist[cur[1]] = 1 -    for x in G[cur[1]]: -        if hist[x] == 0: -            if d[x] > cur[0] + 1: -                d[x] = cur[0] + 1 -                heapq.heappush(heap, (d[x], x)) -if d[N] == 2: +    d, x = heapq.heappop(heap) +    if dist[x] < d: +        continue +    hist[x] = 1 +    for y in G[x]: +        if hist[y] == 0 and dist[y] > d + 1: +            dist[y] = d + 1 +            heapq.heappush(heap, (d + 1, y)) +if dist[N] == 2: