CodeEff/ECCO huggingface dataset:
# Original solution
import queue
n,m = list(map(int,input().split()))

adj = [[] for i in range(n)]
dist = [-1]*n
for i in range(m):
    a,b = list(map(int,input().split()))
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)
    
q = queue.Queue()
dist[0] = 0
q.put(0)

while not q.empty():
    x = q.get()
    
    for f in adj[x]:
        if dist[f] != -1:
            continue
        
        dist[f] = dist[x] + 1
        q.put(f)
     
if dist[n-1] == 2:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

# Optimized solution
from collections import deque
n,m = list(map(int,input().split()))

adj = [[] for i in range(n)]
dist = [-1]*n
for i in range(m):
    a,b = list(map(int,input().split()))
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)
    
q = deque()
dist[0] = 0
q.append(0)

while len(q) > 0:
    x = q.popleft()
    
    for f in adj[x]:
        if dist[f] != -1:
            continue
        
        dist[f] = dist[x] + 1
        q.append(f)
     
if dist[n-1] == 2:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
# Original solution
N, M = [int(_) for _ in input().split()]
ab = [input().split() for _ in range(M)]
N = str(N)

ne = []
for i in ab:
    if i[0] == "1":
        ne += [i[1]]

for j in ab:
    if j[0] in ne and j[1] == N:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

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

goal = {i:0 for i in range(1, N+1)}
N = str(N)

ne = []
for i in ab:
    if i[0] == "1":
        goal[int(i[1])] = 1

for j in ab:
    if goal[int(j[0])] and j[1] == N:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")
# Original solution
N, M = list(map(int,input().split()))
S = []
for i in range(M):
        S.append(list(map(int, input().split())))

toN =[]
first = []
end = False

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

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

for i in toN:
    if end:
        break
    for j in first:
        if end:
            break
        if i == j:
            print("POSSIBLE")
            end = True
            break


if not end:
    print("IMPOSSIBLE")

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

toN =[]
first = []
end = False

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

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

toN = set(toN)
first = set(first)

if toN.intersection(first):
    print("POSSIBLE")

else:
    print("IMPOSSIBLE")
# Original solution
N, M = list(map(int, input().split()))
ans = 'IMPOSSIBLE'
abl1 = []
abl2 = []
for _ in range(M):
    ab = list(map(int,input().split()))
    if ab[0] == 1:
        abl1.append(ab)
    elif ab[1] == N:
        abl2.append(ab)
    for i in abl1:
        if [i[1], N] in abl2:
            ans = 'POSSIBLE'
print(ans)

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

abl1 = set()
abl2 = set()
for _ in range(M):
    ab = list(map(int,input().split()))
    if ab[0] == 1:
        abl1.add(ab[1])
    elif ab[1] == N:
        abl2.add(ab[0])


for i in abl1:
   if i in abl2:
       print("POSSIBLE")
       exit()
print("IMPOSSIBLE")
# Original solution
import collections

n,m = list(map(int,input().split()))
s = [list(map(int,input().split())) for i in range(m)]

q = collections.deque()
for i in range(m):
    if s[i][0] == 1:
        q.append(s[i][1])

for i in s:
    for j in q:
        if j in i and n in i:
            print("POSSIBLE")
            exit()
print("IMPOSSIBLE")




# Optimized solution
n,m = list(map(int,input().split()))

s1 = set()
s2 = set()
for i in range(m):
    a,b = list(map(int,input().split()))
    if a == 1:
        s1.add(b)
    elif b == 1:
        s1.add(a)
    elif a == n:
        s2.add(b)
    elif b == n:
        s2.add(a)

if s1.isdisjoint(s2):
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")
# Original solution
n, m = list(map(int, input().split()))
P, M = ("POSSIBLE", "IMPOSSIBLE")
dic = {}
for _ in range(m):
    a, b = list(map(int, input().split()))
    if dic.get(a) is None: dic[a] = [b]
    else: dic[a] = dic[a] + [b]
    if dic.get(b) is None: dic[b] = [a]
    else: dic[b] = dic[b] + [a]
if dic.get(n) is None:
    print(M)
    exit()
arr = dic[n]
for i in arr:
    if 1 in dic[i]:
        print(P)
        exit()
print(M)

# Optimized solution
def answer(destination, services):
    P, M = ("POSSIBLE", "IMPOSSIBLE")
    dic = {}
    for a, b in services:
        if dic.get(a) is None:
            dic[a] = [b]
        else:
            dic[a].append(b)
        if dic.get(b) is None:
            dic[b] = [a]
        else:
            dic[b].append(a)
    if dic.get(destination) is None: return M
    arr = dic[destination]
    for i in arr:
        if 1 in dic[i]:
            return P
    return M

n, m = list(map(int, input().split()))
services = []
for _ in range(m):
    a, b = list(map(int, input().split()))
    services.append((a, b))
print((answer(n, services)))
# Original solution
N, M = list(map(int,input().split()))
AB = []
for _ in range(M):
    a,b = list(map(int,input().split()))
    if  a == 1 or b== N:
        AB.append((a,b))
AB = set(AB)
for ab in AB:
    if ab[0] == 1:
        for  cd in AB:
            if cd[1] == N and ab[1] == cd[0]:
                    print("POSSIBLE")
                    exit()
print("IMPOSSIBLE")

# Optimized solution
N, M = list(map(int,input().split()))
AB = []
for _ in range(M):
    a,b = list(map(int,input().split()))
    if  a == 1 or b== N:
        AB.append((a,b))
set1 = set()
set2 = set()
for ab in AB:
    if ab[0] == 1:
        set1.add(ab[1])
    if ab[1] == N:
        set2.add(ab[0])
if set1 & set2:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
# Original solution
n,m=list(map(int,input().split()))
first=[]
second=[]
for i in range(m):
    ai,bi=list(map(int,input().split()))
    if ai==1:
        first.append(bi)
    elif bi==n:
        second.append(ai)
    fset,sset=set(first),set(second)
if len(list(fset&sset))>=1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

# Optimized solution
n,m=list(map(int,input().split()))
check=[0]*n
ans="IMPOSSIBLE"
for i in range(m):
    ai,bi=list(map(int,input().split()))
    if ai==1:
        if check[bi-1]==1:
            ans="POSSIBLE"
            break
        else:
            check[bi-1]+=1
    elif bi==n:
        if check[ai-1]==1:
            ans="POSSIBLE"
            break
        else:
            check[ai-1]+=1
print(ans)
# Original solution
N, M, *A = list(map(int, open(0).read().split()))
A = [(A[i], A[i+1]) for i in range(0, M*2, 2)]
E = [[] for _ in range(N)]
for a, b in A:
    a -= 1; b -= 1
    E[a].append(b)
    E[b].append(a)

def search(d=2, v=0, g=N-1):
    if d == 0:
        if v == g:
            return True
        else:
            return False

    for to in E[v]:
        if search(d-1, to, g):
            return True
    return False

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

# Optimized solution
import sys
input = sys.stdin.readline
N, M = list(map(int, input().split()))
G = [[] for _ in [0]*N]
for _ in [0]*M:
    a, b = list(map(int, input().split()))
    a -= 1; b -= 1
    G[a].append(b)
    G[b].append(a)

for v in G[0]:
    if N-1 in G[v]:
        print('POSSIBLE')
        break
else:
    print('IMPOSSIBLE')
# Original solution
N,M = list(map(int,input().split(" ")))
first = []
second = []
flag = 0

for i in range(M):
  a,b = list(map(int,input().split(" ")))
  if b == N:
    second.append(a)
  if a == 1:
    first.append(b)
    
if len(first) == 0 or len(second) == 0:
  print("IMPOSSIBLE")
else:
  for j in range(len(first)):
    for k in range(len(second)):
      if first[j] == second[k]:
        print("POSSIBLE")
        flag = 1
        break
  if flag == 0:
    print("IMPOSSIBLE")

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

first = []
second = []
flag = 0
end = True

for i in range(M):
  a,b = list(map(int,input().split(" ")))
  if b == N:
    second.append(a)
  if a == 1:
    first.append(b)

first.sort()
second.sort()
    
if len(first) == 0 or len(second) == 0:
  print("IMPOSSIBLE")
else:
  firsti = 0
  secondi = 0
  while(end == True):
    if first[firsti] == second[secondi]:
      print("POSSIBLE")
      break
    elif first[firsti] < second[secondi]:
      firsti += 1
      if firsti > len(first) - 1:
        print("IMPOSSIBLE")
        break
    else:
      secondi += 1
      if secondi > len(second) - 1:
        print("IMPOSSIBLE")
        break
# Original solution
n,m=list(map(int,input().split()));a,b=[],[]
for i in range(m):
  aa,bb=list(map(int,input().split()))
  a.append(aa);b.append(bb)
c=[]
for i in range(m):
  if a[i]==1:c.append(b[i])
for i in range(m):
  if b[i]==n:
    if a[i] in c:print("POSSIBLE");exit()
print("IMPOSSIBLE")

# Optimized solution
n,m=list(map(int,input().split()));a=[]
for i in range(m):
  aa,bb=list(map(int,input().split()))
  if aa==1:a.append(bb)
  if bb==n:a.append(aa)
a.sort()
for i in range(len(a)-1):
  if a[i]==a[i+1]:print("POSSIBLE");exit()
print("IMPOSSIBLE")
# Original solution
n,m=list(map(int,input().split()));a=[]
for i in range(m):
  aa,bb=list(map(int,input().split()))
  if aa==1:a.append(bb)
  if bb==n:a.append(aa)
a.sort()
for i in range(len(a)-1):
  if a[i]==a[i+1]:print("POSSIBLE");exit()
print("IMPOSSIBLE")

# Optimized solution
n,m=list(map(int,input().split()))
s,t=set(),set()
for _ in range(m):
  a,b=list(map(int,input().split()))
  if a==1:t.add(b)
  if b==n:s.add(a)
if s&t:print("POSSIBLE")
else:print("IMPOSSIBLE")
# Original solution
n, m = list(map(int, input().split()))

transit = []
transit_ = []

for a,b in (list(map(int, input().split())) for _ in range(m)):
    if a == 1:
        transit.append(b)
    if b == n:
        transit_.append(a)

if set(transit)&set(transit_):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

# Optimized solution
import sys
input = sys.stdin.readline

n, m = list(map(int, input().split()))

transit = []
transit_ = []

for a,b in (list(map(int, input().split())) for _ in range(m)):
    if a == 1:
        transit.append(b)
    if b == n:
        transit_.append(a)

if set(transit)&set(transit_):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
# Original solution
import itertools


N, M = list(map(int, input().split()))
AB = [tuple(sorted(map(int, input().split(' ')))) for _ in range(M)]

ans = 0
for i in range(2, N):
    if tuple([1, i]) in AB and tuple([i, N]) in AB:
        print('POSSIBLE')
        break
else:
    print('IMPOSSIBLE')


# Optimized solution
n, m = list(map(int, input().split()))
sa = set()
sb = set()
for _ in range(m):
    a, b = list(map(int, input().split()))
    if a == 1:
        sb.add(b)
    if b == n:
        sa.add(a)

print(('POSSIBLE' if len(sa&sb) != 0 else 'IMPOSSIBLE'))
# Original solution
n, m = list(map(int, input().split()))
first = [0]
a = 1
for i in range(0, m):
	b = (list(map(int, input().split())))
	if b[0] == 1:
		if b[1] in first:
			print('POSSIBLE')
			a = 0
			break
		else:
			first.append(b[1])
	if b[1] == n:
		if b[0] in first:
			print('POSSIBLE')
			a = 0
			break
		else:
			first.append(b[0])
		
if a:
	print('IMPOSSIBLE')

# Optimized solution
n, m = list(map(int, input().split()))
des= [0]*(n+1)
a = 1
for i in range(0, m):
	b = (list(map(int, input().split())))
	if b[0] == 1:
		des[b[1]] += 1
		if des[b[1]] == 2:
			print('POSSIBLE')
			a = 0
			break
	if b[1] == n:
		des[b[0]] += 1
		if des[b[0]] == 2:
			print('POSSIBLE')
			a = 0
			break
		
if a:
	print('IMPOSSIBLE')
# Original solution
from collections import deque
N,M=list(map(int,input().split()))

sa=deque([])
en=deque([])
for _ in range(M):
    a,b=list(map(int,input().split()))
    if a==1:
        sa.append(b)
    elif b==N:
        en.append(a)
print(('POSSIBLE' if any([x in en for x in sa]) else 'IMPOSSIBLE'))

# Optimized solution
N,M=list(map(int,input().split()))
AB=[[int(x) for x in input().split()] for _ in range(M)]
sa=set()
en=set()
for a,b in AB:
    if a>b:
        a,b=b,a
    if a==1:
        sa.add(b)
    if b==N:
        en.add(a)
print(('POSSIBLE' if sa&en else 'IMPOSSIBLE'))
# Original solution
n, m = list(map(int, input().split()))
a = [input().split() for _ in range(m)]
A = set()
B = set()

for i in range(m):
    if a[i][0] == "1":
        A.add(a[i][1])
    if a[i][1] == str(n):
        B.add(a[i][0])
    if A & B:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")


# Optimized solution
n, m = list(map(int, input().split()))
a = [input().split() for _ in range(m)]
A = []
B = []

for i in range(m):
    if a[i][0] == "1":
        A.append(a[i][1])
    if a[i][1] == str(n):
        B.append(a[i][0])
print(("POSSIBLE" if set(A) & set(B) else "IMPOSSIBLE"))
# Original solution
n,m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]
ab.sort()
AB = sorted(ab, reverse=True, key=lambda x:x[1])
s = []
ans = "IMPOSSIBLE"
for a,b in ab:
    if a == 1: s.append(b)
    else: break
for A, B in AB:
    if B == n:
        if A in s:
            ans = "POSSIBLE"
    else: break
print(ans)

# Optimized solution
n,m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]
ab.sort()
AB = sorted(ab, reverse=True, key=lambda x:x[1])
s = [0] * n
ans = "IMPOSSIBLE"
for a,b in ab:
    if a == 1: s[b-1] = 1
    else: break
for A, B in AB:
    if B == n:
        if s[A-1] == 1:
            ans = "POSSIBLE"
    else: break
print(ans)
# Original solution
n,m = list(map(int, input().split()))
s = []
g = []
for _ in range(m):
  a,b = list(map(int, input().split()))
  if a == 1: s.append(b)
  elif b == n: g.append(a)
s.sort()
g.sort()
if min(len(s), len(g)) == len(g): x,y = g,s
else: x,y = s,g
  
ok = False
for v in x:
  if v in y: 
    ok = True
    break
print(("POSSIBLE" if ok else "IMPOSSIBLE"))

# Optimized solution
n,m = list(map(int, input().split()))
l = [0] * (n+1)
for _ in range(m):
  a,b = list(map(int, input().split()))
  if a == 1: l[b] += 1
  if b == n: l[a] += 1

print(("POSSIBLE" if 2 in l else "IMPOSSIBLE"))
# Original solution
n,m = list(map(int, input().split()))
l = [0] * (n+1)
for _ in range(m):
  a,b = list(map(int, input().split()))
  if a == 1: l[b] += 1
  if b == n: l[a] += 1

print(("POSSIBLE" if 2 in l else "IMPOSSIBLE"))

# Optimized solution
n,m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]
start = []
goal = []
for a,b in ab:
    if a == 1: start.append(b)
    elif b == n: goal.append(a)
print(("POSSIBLE" if list(set(start) & set(goal)) else "IMPOSSIBLE"))
# Original solution
import sys
from collections import defaultdict


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

inter = []
goalable = defaultdict(lambda: False)
for i in range(M):
  start, end = list(map(int, input().split()))
  if start == 1:
    inter.append(end)
  else:
    if end == N: 
      goalable[start] = True
      
for i in inter:
  if goalable[i]:
    print("POSSIBLE")
    sys.exit()
    
print("IMPOSSIBLE")

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

inter, goalable = set(), set()
for i in range(M):
  a, b = list(map(int, input().split()))
  if a == 1:
    inter.add(b)
    
  if b == N: 
    goalable.add(a)
      
flag = inter & goalable
print(("POSSIBLE" if flag else "IMPOSSIBLE"))
# Original solution
n,m = list(map(int,input().split()))
a = [0 for _ in range(m)]
b = [0 for _ in range(m)]

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

go = []

for i in range(len(a)):
    if (a[i] == 1):
        go.append(b[i])
        a[i],b[i] == 0,0
u = 0
t = len(a)
while(u < t):
    if a[u] == 0:
        del(a[u])
        del(b[u])
        t -= 1
    if b[u] != n:
        del(a[u])
        del(b[u])
        t -= 1
    u += 1

for i in range(len(go)):
    for j in range(len(a)):
        if(go[i] == a[j]):
            if(b[j] == n):
                print("POSSIBLE")
                exit()

print("IMPOSSIBLE")

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

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

go = []
goal = []

for i in range(len(a)):
    if a[i] == 1:
        go.append(b[i])
    if b[i] == n:
        goal.append(a[i])

count = [0 for i in range(n)]
for i in range(len(go)):
    count[go[i]-1] = 1
for i in range(len(goal)):
    count[goal[i]-1] += 1
for i in range(len(count)):
    if count[i] > 1:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")
# Original solution
a=input().split()
N=int(a[0])
M=int(a[1])
first=[]
second=[]
i=0
while i<M:
	y=input().split()
	if int(y[0])==1:
		first.append(y[1])
	elif int(y[1])==N:
		second.append(y[0])
	i+=1

if any(i in first for i in second):
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")

# Optimized solution
a=input().split()
N=int(a[0])
M=int(a[1])
first=[]
second=[]
i=0
while i<M:
	y=input().split()
	if int(y[0])==1:
		first.append(y[1])
	elif int(y[1])==N:
		second.append(y[0])
	i+=1

first=set(first)
second=set(second)
if len(first.intersection(second))>0:
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")
# Original solution
N, M = list(map(int, input().split()))
X, Y = [],[]
for i in range(M):
    A, B = list(map(int, input().split()))
    if A == 1:
        X.append(B)
    elif B == N:
        Y.append(A)

for i in X:
    for j in Y:
        if i == j:
            print("POSSIBLE")
            exit(0)
print("IMPOSSIBLE")

# Optimized solution
N, M = list(map(int, input().split()))
cnt = [0]*N
for i in range(M):
    A, B = list(map(int, input().split()))
    if A == 1:
        cnt[B] += 1
    elif B == N:
        cnt[A] += 1

if 2 in cnt:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
# Original solution
n,m = list(map(int, input().split()))
ab = []
num = 0
for i in range(m):
    a,b = list(map(int, input().split()))
    if a == 1 or b == n:
        num += 1
        ab.append((a,b))
ab.sort()
x = 'IMPOSSIBLE'
for h in range(num):
    if (ab[h][1],n) in ab:
        x = 'POSSIBLE'
        break
print(x)

# Optimized solution
n,m = list(map(int, input().split()))
b1 = []
b2 = []
for i in range(m):
    a,b = list(map(int, input().split()))
    if a == 1:
        b1.append(b)
    if b == n:
        b2.append(a)
if len(b1) + len(b2) == len(list(set(b1+b2))):
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')
# Original solution
import sys
from collections import deque
l = deque(sys.stdin.readlines())
n, m = (int(x) for x in l[0].split())
l.popleft()

from_1, to_n = set(), set()
for a, b in deque((int(x) for x in l[i].split()) for i in range(m)):
    if a == 1: from_1.add(b)
    elif b == n: to_n.add(a)

print(("POSSIBLE" if from_1 & to_n else "IMPOSSIBLE"))

# Optimized solution
import sys
l = sys.stdin.readlines()
n, m = (int(x) for x in l[0].split())

from_1, to_n = set(), set()
for a, b in ((int(x) for x in l[i].split()) for i in range(1, m+1)):
    if a == 1: from_1.add(b)
    elif b == n: to_n.add(a)

print(("POSSIBLE" if from_1 & to_n else "IMPOSSIBLE"))
# Original solution
import sys
l = sys.stdin.readlines()
n, m = (int(x) for x in l[0].split())

from_1, to_n = set(), set()
for a, b in ((int(x) for x in l[i].split()) for i in range(1, m+1)):
    if a == 1: from_1.add(b)
    elif b == n: to_n.add(a)

print(("POSSIBLE" if from_1 & to_n else "IMPOSSIBLE"))


# Optimized solution
import sys
l = sys.stdin.readlines()
n, m = l[0].split()

from_1, to_n = set(), set()
for a, b in (l[i].split() for i in range(1, int(m)+1)):
    if a == '1': from_1.add(b)
    elif b == n: to_n.add(a)

print(("POSSIBLE" if from_1 & to_n else "IMPOSSIBLE"))
# Original solution
import sys
input = sys.stdin.readline


def read():
    N, M = list(map(int, input().strip().split()))
    AB = []
    for i in range(M):
        a, b = list(map(int, input().strip().split()))
        AB.append((a, b))
    return N, M, AB


def solve(N, M, AB):
    S = [False for i in range(N+1)]
    T = [False for i in range(N+1)]
    for a, b in AB:
        if a > b:
            a, b = b, a
        if a == 1:
            S[b] = True
        elif b == N:
            T[a] = True
    for s, t in zip(S, T):
        if s and t:
            return "POSSIBLE"
    return "IMPOSSIBLE"


if __name__ == '__main__':
    inputs = read()
    print(("%s" % solve(*inputs)))


# Optimized solution
import sys
input = sys.stdin.readline


def read():
    N, M = list(map(int, input().strip().split()))
    AB = []
    for i in range(M):
        a, b = list(map(int, input().strip().split()))
        AB.append((a, b))
    return N, M, AB


def solve(N, M, AB):
    is_ok = True
    mid_b = set()
    mid_a = set()
    for a, b in AB:
        if a == 1:
            mid_b.add(b)
        elif b == N:
            mid_a.add(a)
    is_ok = len(mid_a.intersection(mid_b)) > 0
    return "POSSIBLE" if is_ok else "IMPOSSIBLE"


if __name__ == '__main__':
    inputs = read()
    print((solve(*inputs)))
# Original solution
N, M = list(map(int,input().split()))
P = [list(map(int,input().split())) for _ in range(M)]
P.sort()
Q = []
s = -1
ans = ("IMPOSSIBLE")
for i in range (M):
    if P[i][0] == 1:
        Q.append(P[i][1])
    else:
        s = i - 1
        break
if s >= 0:
    for j in range(s, M):
        if P[j][1] == N:
            if P[j][0] in Q:
                ans = ("POSSIBLE")
print(ans)

# Optimized solution
N, M = list(map(int,input().split()))
P = [list(map(int,input().split())) for _ in range(M)]
P.sort()
q = -1
ans = ("IMPOSSIBLE")
for i in range (M):
    if P[i][0] == 1:
        p = P[i][1]
        if q < 0:
            if i > 0:
                q = i - 1
            else:
                q = 0
        for j in range(q, M):
            if P[j][0] == p:
                if P[j][1] == N:
                    ans = ("POSSIBLE")
                    break
            elif P[j][0] > p:
                if q >= 0:
                    q = j - 1
                else:
                    q = 0
                break
    else:
        break
print(ans)
# Original solution
N, M = list(map(int,input().split()))

#訪れることができるかのリスト
lst = [0] * N

flag = False #フラグを立てる
for i in range(M): #M種の定期船について確認
    a, b = list(map(int,input().split()))
    if a == 1: #スタートが1の時
        if lst[b-1] == 1: #Nから1回で来る船があるならOK
            flag = True
        else:
            lst[b-1] = 1 #Nから1回で来る船がない時、1からは1回で来れることをメモ
    if b == N: #ゴールがNの時
        if lst[a-1] == 1: #1から1回で来る船があるならOK
            flag = True
        else:
            lst[a-1] = 1 #1から1回で来る船がない時、Nからは1回で来れることメモ

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




# Optimized solution
import sys
input = sys.stdin.readline

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

G = [tuple(map(int, input().split())) for _ in range(M)]
G.sort(key = lambda x: x[0])

check = [False] * (N + 1)

for a, b in G:
    if a == 1:
        check[b] = True
    else:
        if check[a] and b == N:
            print ('POSSIBLE')
            exit()

print ('IMPOSSIBLE')
# Original solution
n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]


arr = []
for x in ab:
    if n in x:
        if x.index(n) == 0:
            arr.append(x[1])
        else:
            arr.append(x[0])

for a, b in ab:
    if a in arr:
        if b == 1:
            print('POSSIBLE')
            exit()
    if b in arr:
        if a == 1:
            print('POSSIBLE')
            exit()

print('IMPOSSIBLE')


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


s = set()
for x in ab:
    if n in x:
        if x.index(n) == 0:
            s.add(x[1])
        else:
            s.add(x[0])

for a, b in ab:
    if a in s:
        if b == 1:
            print('POSSIBLE')
            exit()
    if b in s:
        if a == 1:
            print('POSSIBLE')
            exit()

print('IMPOSSIBLE')
# Original solution
N,M=list(map(int,input().split()))
sa=set()
sb=set()
for i in range(M):
    a,b=list(map(int,input().split()))
    if a==1:sb.add(b)
    if b==N:sa.add(a)
print(("IMPOSSIBLE" if len(sa&sb)==0 else "POSSIBLE"))


# Optimized solution
n, m = list(map(int, input().split()))
sa = set()
sb = set()

for i in range(m):
    a, b = list(map(int, input().split()))
    if a == 1:
        sb.add(b)
    if b == n:
        sa.add(a)

print(('IMPOSSIBLE' if len(sa & sb) == 0 else 'POSSIBLE'))