from collections import deque



def bfs(graph:list, node:int, start:int) -> list:

    # 未探索のノードは距離INF

    INF = float("inf")

    dist = [INF]*node

    

    # 始点ノードの距離を0とし、dfsのためのstackを作成

    dist[start] = 0

    que = deque([(0,start)])

    

    # 未探索のノードをqueueに入れる

    while que:

        cost, cur_node = que.popleft()

        

        for nex_cost, nex_node in graph[cur_node]:

            if dist[nex_node] != INF:

                continue

            else:

                dist[nex_node] = dist[cur_node] + nex_cost

                que.append((dist[nex_node], nex_node))

                

    return dist



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

AB = []

for i in range(M):

    AB.append(tuple(map(int, input().split())))

    

#N,M = 4,3

#AB = [(1,2),(2,3),(3,4)]



adj_list = [[] for _ in range(N)]

for a,b in AB:

    a -= 1

    b -= 1

    adj_list[a].append((1,b))

    adj_list[b].append((1,a))

    

dist = bfs(adj_list, N, 0)



if dist[N-1] == 2:

    print("POSSIBLE")

else:

    print("IMPOSSIBLE")
import sys

sdin = sys.stdin.readline



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

AB = []

for i in range(M):

    AB.append(tuple(map(int, sdin().split())))

    

to_mid = set()

from_mid = set()



for a,b in AB:

    if a==1:

        to_mid.add(b)

    if b==N:

        from_mid.add(a)

        

if to_mid & from_mid:

    print("POSSIBLE")

else:

    print("IMPOSSIBLE")

from collections import deque


def bfs(graph: list, node: int, start: int) -> list:
    # 未探索のノードは距離INF
    INF = float("inf")
    dist = [INF] * node
    # 始点ノードの距離を0とし、dfsのためのstackを作成
    dist[start] = 0
    que = deque([(0, start)])
    # 未探索のノードをqueueに入れる
    while que:
        cost, cur_node = que.popleft()
        for nex_cost, nex_node in graph[cur_node]:
            if dist[nex_node] != INF:
                continue
            else:
                dist[nex_node] = dist[cur_node] + nex_cost
                que.append((dist[nex_node], nex_node))
    return dist


N, M = list(map(int, input().split()))
AB = []
for i in range(M):
    AB.append(tuple(map(int, input().split())))
# N,M = 4,3
# AB = [(1,2),(2,3),(3,4)]
adj_list = [[] for _ in range(N)]
for a, b in AB:
    a -= 1
    b -= 1
    adj_list[a].append((1, b))
    adj_list[b].append((1, a))
dist = bfs(adj_list, N, 0)
if dist[N - 1] == 2:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

import sys

sdin = sys.stdin.readline
N, M = list(map(int, sdin().split()))
AB = []
for i in range(M):
    AB.append(tuple(map(int, sdin().split())))
to_mid = set()
from_mid = set()
for a, b in AB:
    if a == 1:
        to_mid.add(b)
    if b == N:
        from_mid.add(a)
if to_mid & from_mid:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

-from collections import deque +import sys - -def bfs(graph: list, node: int, start: int) -> list: -    # 未探索のノードは距離INF -    INF = float("inf") -    dist = [INF] * node -    # 始点ノードの距離を0とし、dfsのためのstackを作成 -    dist[start] = 0 -    que = deque([(0, start)]) -    # 未探索のノードをqueueに入れる -    while que: -        cost, cur_node = que.popleft() -        for nex_cost, nex_node in graph[cur_node]: -            if dist[nex_node] != INF: -                continue -            else: -                dist[nex_node] = dist[cur_node] + nex_cost -                que.append((dist[nex_node], nex_node)) -    return dist - - -N, M = list(map(int, input().split())) +sdin = sys.stdin.readline +N, M = list(map(int, sdin().split())) -    AB.append(tuple(map(int, input().split()))) -# N,M = 4,3 -# AB = [(1,2),(2,3),(3,4)] -adj_list = [[] for _ in range(N)] +    AB.append(tuple(map(int, sdin().split()))) +to_mid = set() +from_mid = set() -    a -= 1 -    b -= 1 -    adj_list[a].append((1, b)) -    adj_list[b].append((1, a)) -dist = bfs(adj_list, N, 0) -if dist[N - 1] == 2: +    if a == 1: +        to_mid.add(b) +    if b == N: +        from_mid.add(a) +if to_mid & from_mid: