CodeEff/ECCO huggingface dataset:
# Original solution
import sys
n,m = list(map(int,input().split()))
a = [list(map(int,input().split())) for _ in range(m)]
start = a[0][0]
goal = n
tmp,ans = [],[]
for i in range(m):
	if a[i][1] == goal:
		tmp.append(a[i][0])
#print(tmp)
for j in range(m):
		if a[j][0] == start:
			if a[j][1] in tmp:
				print('POSSIBLE')
				sys.exit()
print('IMPOSSIBLE')


# Optimized solution
import sys
n,m = list(map(int,input().split()))
a = [list(map(int,input().split())) for _ in range(m)]
start = a[0][0]
goal = n
tmp,ans = [],[]
for i in range(m):
	if a[i][1] == goal:
		tmp.append(a[i][0])
#print(tmp)
for j in range(m):
		if a[j][0] == start:
			ans.append(a[j][1])
if len(set(tmp)&set(ans)) > 0:
	print('POSSIBLE')
	sys.exit()
print('IMPOSSIBLE')
# Original solution
n,m = list(map(int,input().split()))
li = [[0 for _ in range(n)] for _ in range(n)]
for i in range(m):
    a,b = list(map(int,input().split()))
    a-=1
    b-=1
    li[a][b] = 1
    li[b][a] = 1

ans = False
for i in range(1,n-1):
    if li[0][i] and li[i][n-1]:
        ans = True
        break

if ans:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

# Optimized solution
n,m = list(map(int,input().split()))
li1 = [0 for _ in range(n)]
li2 = [0 for _ in range(n)]

for i in range(m):
    a,b = list(map(int,input().split()))
    a-=1
    b-=1
    if a==0:
        li1[b] = 1
    elif b==n-1:
        li2[a] = 1

ans = False
for i in range(1,n-1):
    if li1[i] and li2[i]:
        ans = True
        break

if ans:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
# Original solution
n,m=list(map(int,input().split()))
a,b=[0]*m,[0]*m
for i in range(m):
    a[i],b[i] = list(map(int,input().split()))
    
for i in range(m):
    if a[i]==1:
        p=b[i]
        for j in range(m):
            if a[j]==p and b[j]==n:
                print('POSSIBLE')
                exit()
print('IMPOSSIBLE')

# Optimized solution
n,m=list(map(int,input().split()))
a,b=[0]*m,[0]*m
c=[False]*(n+1)
d=[False]*(n+1)
for i in range(m):
    a[i],b[i] = list(map(int,input().split()))
    if a[i]==1: c[b[i]]=True
    if b[i]==n: d[a[i]]=True
for i in range(n):
    if c[i] and d[i]:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')
# Original solution
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")

# Optimized solution
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")
# Original solution
N,M = list(map(int,input().split()))
onelist,nlist = [],[]
for i in range(M):
    aa,bb = list(map(int,input().split()))
    if aa == 1:
        onelist.append(bb)
    if bb == N:
        nlist.append(aa)

for b in onelist:
    if b in nlist:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")


# Optimized solution
N,M = list(map(int,input().split()))
onelist,nlist = [],[]
for i in range(M):
    aa,bb = list(map(int,input().split()))
    if aa == 1:
        onelist.append(bb)
    if bb == N:
        nlist.append(aa)


if len(set(onelist) & set(nlist)) == 0:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")
# Original solution
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")

# Optimized solution
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")
# Original solution
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(eval(input()))
def i_map(): return list(map(int, input().split()))
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return eval(input())
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

import string

def main():
    n,m = i_map()

    c = [[INF]*n for _ in range(n)]
    for i in range(n):
        c[i][i] = 0

    for _ in range(m):
        a,b = i_map()
        c[a-1][b-1] = 1
        c[b-1][a-1] = 1

    for i,k in enumerate(c[0]):
        pass
        if k == 1:
            if c[i][-1] == 1:
                print("POSSIBLE")
                exit()
    print("IMPOSSIBLE")





if __name__=="__main__":
    main()


# Optimized solution
N, M = list(map(int, input().split()))
L = [list(map(int, input().split())) for i in range(M)]
s = []
g = []
for i in range(M):
    if 1 == L[i][0]:
        s.append(L[i][1])
    if 1 == L[i][1]:
        s.append(L[i][0])
        
for i in range(M):
    if N == L[i][0]:
        g.append(L[i][1])
    if N == L[i][1]:
        g.append(L[i][0])
        
if set(g)&set(s):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
# Original solution
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(eval(input()))
def i_map(): return list(map(int, input().split()))
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return eval(input())
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

import string

def main():
    n,m = i_map()

    c = [[INF]*n for _ in range(n)]
    for i in range(n):
        c[i][i] = 0

    for _ in range(m):
        a,b = i_map()
        c[a-1][b-1] = 1
        c[b-1][a-1] = 1

    for i,k in enumerate(c[0]):
        if k == 1:
            if c[i][-1] == 1:
                print("POSSIBLE")
                exit()
    print("IMPOSSIBLE")


if __name__=="__main__":
    main()


# Optimized solution
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(eval(input()))
def i_map(): return list(map(int, input().split()))
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return eval(input())
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

import string

def main():
    n,m = i_map()
    s = set()
    g = set()

    for _ in range(m):
        a,b = i_map()
        if a == 1:
            s.add(b)
        elif b == 1:
            s.add(a)
        elif a == n:
            g.add(b)
        elif b == n:
            g.add(a)

    if s&g:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

if __name__=="__main__":
    main()
# Original solution
n, m = list(map(int, input().split()))
ship = {i:[] for i in range(1, n+1)}

for _ in range(m):
    a, b = list(map(int, input().split()))
    ship[a].append(b)

for i in ship[1]:
    if n in ship[i]:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

# Optimized solution
n, m = list(map(int, input().split()))
ship = {i:False for i in range(1, n+1)}
bl = []
for _ in range(m):
    a, b = list(map(int, input().split()))
    if a == 1:
        ship[b] = True
    elif b == n:
        bl.append(a)

for i in bl:
    if ship[i] == True:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")
# Original solution
n,m=list(map(int,input().split()))
l=[list(map(int,input().split())) for i in range(m)]
#print(n,m,l)
def bin_search(a,li):
    max_len=len(li)
    min_len=0
    while max_len>min_len:
        mid=(max_len+min_len)//2
        if li[mid]==a:
            return True
        elif abs(min_len-max_len)==1 and min_len>=0 and li[min_len]!=a and max_len<len(li) and li[max_len]!=a:
            break
        elif li[mid]<a:
            min_len=mid
        else:
            max_len=mid
s=[]
g=[]
for i in l:
    if i[0]==1:
        s.append(i[1])
    if i[1]==n:
        g.append(i[0])
g.sort
for i in s:
    if bin_search(i,g):
        print('POSSIBLE')
        break
else:
    print('IMPOSSIBLE')

# Optimized solution
n,m=list(map(int,input().split()))
l=[list(map(int,input().split())) for i in range(m)]
#print(n,m,l)
def bin_search(a,li):
    max_len=len(li)-1
    min_len=0
    while max_len>=min_len:
        mid=(max_len+min_len)//2
        if li[mid]==a:
            return True
        elif li[mid]<a:
            min_len=mid+1
        else:
            max_len=mid-1
s=[]
g=[]
for i in l:
    if i[0]==1:
        s.append(i[1])
    if i[1]==n:
        g.append(i[0])
g.sort()
for i in s:
    if bin_search(i,g):
        print('POSSIBLE')
        break
else:
    print('IMPOSSIBLE')
# Original solution
N,M = list(map(int,input().split()))
li = [tuple(map(int,input().split())) for i in range(M)]
numb = [li[i][1] for i in range(M) if li[i][0] == 1]
ans = ''
for i in range(M):
  if li[i][0] in numb and li[i][1] == N:
    ans = 'POSSIBLE'
    break
if ans == '':
  print('IMPOSSIBLE')
else:
  print(ans)
    

# Optimized solution
N,M = list(map(int,input().split()))
li = []
numb = []
for i in range(M):
    a,b = list(map(int,input().split()))
    if a == 1:
        li.append(b)
    elif b == N:
        numb.append(a)
ans = set(li) & set(numb)
if len(ans) >= 1:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
# Original solution
N, M = list(map(int, input().split()))
X = []
Y = []
for i in range(M):
    S, E = list(map(int, input().split()))
    if S == 1:
        X.append(E)
    if E == N:
        Y.append(S)
while 1:
    if X == [] or Y == []:
        print("IMPOSSIBLE")
        break
    min_x = min(X)
    min_y = min(Y)
    if min_x == min_y:
        print("POSSIBLE")
        break
    elif min_x > min_y:
        Y.remove(min_y)
    elif min_x < min_y:
        X.remove(min_x)
else:
    print("IMPOSSIBLE")


# Optimized solution
N, M = list(map(int, input().split()))
X = [0] * N
Y = [0] * N
for i in range(M):
    S, E = list(map(int, input().split()))
    if S == 1:
        X[E-1] = 1
    if E == N:
        Y[S-1] = 1
for i in range(N):
    if X[i] == 1 and Y[i] == 1:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")
# Original solution
N, M = list(map(int, input().split()))
a = [0]*M
b = [0]*M
for i in range(M):
    a[i], b[i] = list(map(int, input().split()))
if N in b and 1 in a:
    for i in range(M):
        for j in range(M):
            if a[j] == 1 and b[i] == N and a[i] == b[j]:
                print('POSSIBLE')
                exit()
            else:
                pass
print('IMPOSSIBLE')

# Optimized solution
n, m = list(map(int, input().split()))
d = {i:[] for i in range(1, n)}
for i in range(m):
    a, b = list(map(int, input().split()))
    d[a].append(b)
ans = "IMPOSSIBLE"
for dd in d[1]:
    if n in d[dd]:
        ans = "POSSIBLE"
        break
print(ans)
# Original solution
import sys
l = list(map(int, input().split(' ')))
N = l[0]
N_ = l[0] + 1
M = l[1]
y = []
u = []

for i in range(M):
    k = list(map(int, input().split()))
    a = k[0]
    b = k[1]
    if (a == 1):
        y.append(b)
    elif (b == N):
        u.append(a)

for i in y:
    if (i in u):
        print('POSSIBLE')
        sys.exit()
print('IMPOSSIBLE')


# Optimized solution
import sys
l = list(map(int, input().split(' ')))
N = l[0]
N_ = l[0] + 1
M = l[1]
y = []
u = set()

for i in range(M):
    k = list(map(int, input().split()))
    a = k[0]
    b = k[1]
    if (a == 1):
        y.append(b)
    elif (b == N):
        u.add(a)

for i in y:
    if (i in u):
        print('POSSIBLE')
        sys.exit()
print('IMPOSSIBLE')
# Original solution
n,m = list(map(int,input().split()))
s = [[int(i) for i in input().split()] for i in range(m)]
d = {}

for i in range(m):
    if s[i][0] == 1:
        d[s[i][1]] = 1
    
for i in range(m):
    if s[i][1] == n and s[i][0] in d:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

# Optimized solution
n,m = list(map(int,input().split()))
d1 = {}
d2 = {}
for i in range(m):
    a,b = list(map(int,input().split()))
    if a == 1: d1[b] = 1
    if b == n: d2[a] = 1

for k in d1:
    if k in d2: 
        ans = "POSSIBLE"
        break
else:
    ans = "IMPOSSIBLE"

print(ans)
# Original solution
N, M = list(map(int, input().split()))
check_1 = []
check_N = []
for i in range(M):
    a, b = list(map(int, input().split()))
    if a == 1:
        check_1.append(b)
    if b == N:
        check_N.append(a)
        
check_1 = list(set(check_1))
chek_N = list(set(check_N))

flag = False
for i in sorted(check_1):
    if i in check_N:
        flag = True
        break
        
if flag:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

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

check_1 = []
check_N = []
for i in range(M):
    a, b = list(map(int, input().split()))
    if a == 1:
        check_1.append(b)
    if b == N:
        check_N.append(a)
        
if len(list(set(check_1) & set(check_N))) > 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
# Original solution
# coding: utf-8
N,M=list(map(int,input().split()))
L=[]
B=[]
flg=0
cnt=0
for i in range(M):
    a,b=list(map(int,input().split()))
    L.append([a,b])
    if a==1:
        B.append(b)
        cnt+=1
#print(L)
ans=[]
for i in range(M):
    for j in range(cnt):
        if L[i][0]==B[j]:
            ans.append(L[i][1])
#print(ans)
if N in ans:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

# Optimized solution
# coding: utf-8
N,M=list(map(int,input().split()))
L=[]
B=[]
A=[]
flg=0
cnt=0
for i in range(M):
    a,b=list(map(int,input().split()))
    L.append([a,b])
    if a==1:
        B.append(b)
        cnt+=1
    elif b==N:
        A.append(a)
        
#print(L)
ans=[]
if len(set(A)&set(B))==0:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')
# Original solution
n,m=list(map(int,input().split()))
A=[]
B=[]
for i in range(m):
  a,b=list(map(int,input().split()))
  if a==1:
    A.append(b)
  if b==n:
    B.append(a)
for i in A:
  if i in B:
    print("POSSIBLE")
    break
else:
  print("IMPOSSIBLE")

# Optimized solution
n,m=list(map(int,input().split()))
A=[]
B=[]
for i in range(m):
  a,b=list(map(int,input().split()))
  if a==1:
    A.append(b)
  if b==n:
    B.append(a)
if len(set(A) & set(B))>0:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")
# Original solution
# -*- coding:utf-8 -*-

def solve():
    N, M = list(map(int, input().split()))
    """
    from1 := 1から行ける島番号のリスト
    toN := Nに行ける島番号のリスト
    from1とtoNの両方に同じ島番号が存在するとき、POSSIBLE
    """
    from1, toN = [], []
    for i in range(M):
        a, b = list(map(int, input().split()))
        if a == 1:
            from1.append(b)
        elif b == N:
            toN.append(a)
    
    for b in from1:
        if b in toN:
            print("POSSIBLE")
            return
    print("IMPOSSIBLE")
        

if __name__ == "__main__":
    solve()


# Optimized solution
# -*- coding:utf-8 -*-

def solve():
    N, M = list(map(int, input().split()))
    """
    from1 := 1から行ける島番号のリスト
    canN[i] := 島iがNに行くことができるか否か
    from1とtoNの両方に同じ島番号が存在するとき、POSSIBLE
    """
    from1 = []
    canN = [False] * (N+1)
    for i in range(M):
        a, b = list(map(int, input().split()))
        if a == 1:
            from1.append(b)
        elif b == N:
            canN[a] = True
    
    for b in from1:
        if canN[b]:
            print("POSSIBLE")
            return
    print("IMPOSSIBLE")
        

if __name__ == "__main__":
    solve()
# Original solution
#2問目
# resultにそれぞれの深さの数を入れていく
N, M = list(map(int, input().split()))
link = [[] for i in range(N)]
for i in range(M):
    A, B = list(map(int, input().split()))
    link[A-1].append(B-1)
    link[B-1].append(A-1)
visited = [-1 for i in range(N)]
Q = [0]
visited[0] = 0

#Qに要素がなくなるまで
while Q:
    #一番上の要素をpop
    v = Q.pop(0)
    for i in link[v]:
        if visited[i] == -1:
            visited[i] = visited[v] + 1
            Q.append(i)

if 0 <= visited[N-1] <= 2: print("POSSIBLE")
else: print("IMPOSSIBLE")

# Optimized solution
#2問目
N, M = list(map(int, input().split()))
link1 = [False for i in range(N+1)]
link2 = [False for i in range(N+1)]
flag = False
for i in range(M):
    A, B = list(map(int, input().split()))
    if A == 1:
        link1[B] = True
    elif B == N:
        link2[A] = True
for i in range(2, N):
    if link1[i] and link2[i]:
        print("POSSIBLE")
        flag = True
        break
if flag == False:
    print("IMPOSSIBLE")
# Original solution
n, m = list(map(int, input().split()))
root_map = dict()
root_map[1] = set()
root_map[n] = set()

for i in range(m):
    a, b = list(map(int, input().split()))
    if a not in root_map:
        root_map[a] = set()
        root_map[a].add(b)
    else:
        root_map[a].add(b)
    if b not in root_map:
        root_map[b] = set()
        root_map[b].add(a)
    else:
        root_map[b].add(a)

for i in root_map[1]:
    if i in root_map[n]:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")


# Optimized solution
n, m = list(map(int, input().split()))
root_map = dict()
root_map[1] = set()
root_map[n] = set()

for i in range(m):
    a, b = list(map(int, input().split()))
    if a == 1 or a == n:
        root_map[a].add(b)
    if b == 1 or b == n:
        root_map[b].add(a)

for i in root_map[1]:
    if i in root_map[n]:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")
# Original solution
N, M = list(map(int, input().split()))
c = []
for i in range(M):
	c.append(list(map(int, input().split())))

for i in range(M):
	if c[i][0] == 1:
		for j in range(M):
			if c[j][0] == c[i][1]:
				if c[j][1] == N:
					print('POSSIBLE')
					exit()

print('IMPOSSIBLE')

# Optimized solution
N, M = list(map(int, input().split()))
c = []
for i in range(M):
	c.append(list(map(int, input().split())))
d = []
e = []


for i in range(M):
	if c[i][0] == 1:
		d.append(c[i][1])

for i in range(M):
	if c[i][1] == N:
		e.append(c[i][0])

l = list(set(d) & set(e))

if l == []:
	print('IMPOSSIBLE')
else:
	print('POSSIBLE')
# Original solution
N, M = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(M)]

S = []
E = []

for i in range(M):
  if ab[i][0] == 1:
    S.append(ab[i][1])
  if ab[i][1] == N:
    E.append(ab[i][0])

#print(S)
#print(E)

flag = False
for s in S:
  if s in E:
    flag = True
    break

if flag:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')


# Optimized solution
N, M = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(M)]

S = []
E = []

for i in range(M):
  if ab[i][0] == 1:
    S.append(ab[i][1])
  if ab[i][1] == N:
    E.append(ab[i][0])

if set(S) & set(E):
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')
# Original solution
N, M = list(map(int,input().split()))
ships = []
for m in range(M):
    ships.append(list(map(int,input().split())))

flag = 0
for n in range(2,N+1):
    if [1,n] in ships and [n,N] in ships:
        print("POSSIBLE")
        flag=1
        break

if flag==0:
    print("IMPOSSIBLE")


# Optimized solution
N, M = list(map(int,input().split()))
ships_1 = []
ships_2 = []
for m in range(M):
    tmp = list(map(int,input().split()))
    if tmp[0]==1:
        ships_1.append(tmp[1])
    elif tmp[1] == N:
        ships_2.append(tmp[0])

matched_list = list(set(ships_1) & set(ships_2))
if matched_list:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
# Original solution
N,M=list(map(int,input().split()))
l,r=[],[]
for i in range(M):
    a,b=list(map(int,input().split()))
    if a==1:l.append([a,b])
    if b==N:r.append([a,b])
for i in l:
    for j in r:
        if i[1]==j[0]:
            print('POSSIBLE')
            exit()
print('IMPOSSIBLE')

# Optimized solution
N,M=list(map(int,input().split()))
l,r=[0]*N,[0]*N
for i in range(M):
    a,b=list(map(int,input().split()))
    if a==1:
        l[b-1]=1
    if b==N:
        r[a-1]=1
for i in range(N):
    if l[i]+r[i]==2:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')
# Original solution
N, M = list(map(int, input().split()))
A = [0 for i in range(200000+1)]
B = [0 for i in range(200000+1)]
ans = 'IMPOSSIBLE'

for i in range(M):
    a, b = list(map(int, input().split()))
    if a == 1:
        A[b] = 1
        if A[b] and B[b]:
            ans = 'POSSIBLE'
            break
    elif b == N:
        B[a] = 1
        if A[a] and B[a]:
            ans = 'POSSIBLE'
            break
print(ans)

# Optimized solution
N, M = list(map(int, input().split()))
A = set()
B = set()

for i in range(M):
    a, b = list(map(int, input().split()))

    if a == 1:
        A.add(b)
    elif b == N:
        B.add(a)

if len(A & B):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
# Original solution
from collections import deque
N, M = list(map(int, input().split()))
lst = [[] for _ in range(N + 1)]
dist = [float("inf")]*(N+1)
for _ in range(M):
    a, b = list(map(int, input().split()))
    lst[a].append(b)
    lst[b].append(a)

q = deque()
d = 0
q.append([1,d])

while q:
    now, d = q.popleft()
    dist[now] = d
    if now == N:
        if d <= 2:
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")
        exit()
    
    for itm in lst[now]:
        if dist[itm] > d+1:
            q.append([itm,d+1])
            
print("IMPOSSIBLE")

# Optimized solution
from collections import deque
N, M = map(int, input().split())
lst = [[] for _ in range(N + 1)]
dist = [float("inf")]*(N+1)
for _ in range(M):
    a, b = map(int, input().split())
    lst[a].append(b)
    lst[b].append(a)

q = deque()
d = 0
q.append([1,d])

while q:
    now, d = q.popleft()
    dist[now] = d

    for itm in lst[now]:
        if dist[itm] > d+1:
            q.append([itm,d+1])
            
print("POSSIBLE") if dist[N] <= 2 else print("IMPOSSIBLE")