CodeEff/ECCO huggingface dataset:
# Original solution
N, M = list(map(int, input().split()))
ab = [sorted(list(map(int, input().split()))) for _ in range(M)]

fst = []
scnd = []

for i in ab:
  if i[0]==1:
    fst.append(i[1])
  if N in i:
    scnd.append(i)

for i in scnd:
  for j in fst:
    if set(i) == set([j, N]):
      print("POSSIBLE")
      exit()
print("IMPOSSIBLE")
  

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

fst = []
scnd = {}

for i in ab:
  if i[0]==1:
    fst.append(i[1])
  if N in i:
    idx = i.index(N)
    scnd[i[1-idx]] = 0

#print(scnd,fst)
    
for j in fst:
  if j in scnd:
    print("POSSIBLE")
    exit()
print("IMPOSSIBLE")
# Original solution
N, M = list(map(int, input().split()))
ab = [sorted(list(map(int, input().split()))) for _ in range(M)]

fst = []
scnd = {}

for i in ab:
  if i[0]==1:
    fst.append(i[1])
  if N in i:
    idx = i.index(N)
    scnd[i[1-idx]] = 0

#print(scnd,fst)
    
for j in fst:
  if j in scnd:
    print("POSSIBLE")
    exit()
print("IMPOSSIBLE")
  

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

cont_1 = set()
cont_n = set()

for ab in AB:
  a, b = ab
  if 1 in ab:
    cont_1.add(a)
    cont_1.add(b)
  if n in ab:
    cont_n.add(a)
    cont_n.add(b)

if cont_1 & cont_n:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")
# Original solution
N, M = list(map(int, input().split()))
start = []
end = []
for i in range(M):
    a, b = list(map(int, input().split()))
    if a == 1 or b == 1:
        start.append(a*b)
    if a == N or b == N:
        end.append(a * b / N)
flag = 0
for i in start:
    if i in end:
        print("POSSIBLE")
        flag = 1
        break
if not(flag):
    print("IMPOSSIBLE")


# Optimized solution
N, M = list(map(int, input().split()))
start = set([])
end = set([])
for i in range(M):
    a, b = list(map(int, input().split()))
    if a == 1 or b == 1:
        start.add(a*b)
    if a == N or b == N:
        end.add(a * b / N)
flag = 0
for i in start:
    if i in end:
        print("POSSIBLE")
        flag = 1
        break
if not(flag):
    print("IMPOSSIBLE")
# Original solution
from _collections import deque
n,m=list(map(int,input().split()))
edg=[[] for i in range(n+1)]
for i in range(m):
    a,b=list(map(int,input().split()))
    edg[a].append(b)
    edg[b].append(a)
dep=[-1]*(n+1)
dep[1]=0
data=deque([1])
while len(data)>0:
    p=data.popleft()
    for i in edg[p]:
        if dep[i]==-1:
            dep[i]=dep[p]+1
            data.append(i)
print(("POSSIBLE" if dep[n]==2 else "IMPOSSIBLE"))



# Optimized solution
n,m=list(map(int,input().split()))
edg=[[] for i in range(n+1)]
for i in range(m):
    a,b=list(map(int,input().split()))
    edg[a].append(b)
    edg[b].append(a)
f=1
for i in range(2,n+1):
    if 1 in edg[i] and n in edg[i]:
        f=0
print(("POSSIBLE" if f==0 else "IMPOSSIBLE"))
# Original solution
n,m=list(map(int,input().split()))
edg=[[] for i in range(n+1)]
for i in range(m):
    a,b=list(map(int,input().split()))
    edg[a].append(b)
    edg[b].append(a)
f=1
for i in range(2,n+1):
    if 1 in edg[i] and n in edg[i]:
        f=0
print(("POSSIBLE" if f==0 else "IMPOSSIBLE"))


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

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

f=1
for i in range(2,n+1):
    if edg1[i]==1 and edgn[i]==1:
        f=0
print(("POSSIBLE" if f==0 else "IMPOSSIBLE"))


# Optimized solution
import sys
input = sys.stdin.readline
from _collections import deque
n,m=list(map(int,input().split()))
edg=[[] for i in range(n+1)]
for i in range(m):
    a,b=list(map(int,input().split()))
    edg[a].append(b)
    edg[b].append(a)
dep=[-1]*(n+1)
dep[1]=0
data=deque([1])
while len(data)>0:
    p=data.popleft()
    for i in edg[p]:
        if dep[i]==-1:
            dep[i]=dep[p]+1
            data.append(i)
print(("POSSIBLE" if dep[n]==2 else "IMPOSSIBLE"))
# Original solution
import sys
def ipnput():
    return sys.stdin.readline()[:-1]
from _collections import deque
n,m=list(map(int,input().split()))
edg=[[] for i in range(n+1)]
for i in range(m):
    a,b=list(map(int,input().split()))
    edg[a].append(b)
    edg[b].append(a)
dep=[-1]*(n+1)
dep[1]=0
data=deque([1])
while len(data)>0:
    p=data.popleft()
    for i in edg[p]:
        if dep[i]==-1:
            dep[i]=dep[p]+1
            data.append(i)
print(("POSSIBLE" if dep[n]==2 else "IMPOSSIBLE"))


# Optimized solution
import sys
input=sys.stdin.readline
from _collections import deque
n,m=list(map(int,input().split()))
edg=[[] for i in range(n+1)]
for i in range(m):
    a,b=list(map(int,input().split()))
    edg[a].append(b)
    edg[b].append(a)
dep=[-1]*(n+1)
dep[1]=0
data=deque([1])
while len(data)>0:
    p=data.popleft()
    for i in edg[p]:
        if dep[i]==-1:
            dep[i]=dep[p]+1
            data.append(i)
print(("POSSIBLE" if dep[n]==2 else "IMPOSSIBLE"))
# Original solution
N, M = list(map(int, input().split()))
ab = [sorted(list(map(int, input().split()))) for _ in range(M)]
judge = False
m = []
for i, (a, b) in enumerate(ab):
    if a == 1:
        m.append(b)

for i, (a, b) in enumerate(ab):
    if a in m and b == N:
        judge = True
        break

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

# Optimized solution
N, M = list(map(int, input().split()))
edge = [[] for _ in range(N)]
for _ in range(M):
    a, b = list(map(int, input().split()))
    a, b = a-1, b-1
    edge[a].append(b)
    edge[b].append(a)

ans = {True: "POSSIBLE",
    False: "IMPOSSIBLE"}

print((ans[len(set(edge[0]) & set(edge[-1])) > 0]))
# Original solution
N,M=list(map(int,input().split()))
import collections
table=collections.defaultdict(list)
for i in range(M):
  a,b=list(map(int,input().split()))
  table[a].append(b)
  table[b].append(a)
for x in table[1]:
  if x in table[N]:
    print("POSSIBLE")
    exit(0)
print("IMPOSSIBLE")
    

# Optimized solution
N,M=list(map(int,input().split()))
import collections
table=collections.defaultdict(int)
table2=collections.defaultdict(int)
for i in range(M):
  a,b=list(map(int,input().split()))
  if a==1:
    table[b]+=1
  if b==N:
    table2[a]+=1
for x in table:
  if x in table2:
    print("POSSIBLE")
    exit(0)
print("IMPOSSIBLE")
# Original solution
N,M=list(map(int,input().split()))
import collections
table=collections.defaultdict(int)
table2=collections.defaultdict(int)
for i in range(M):
  a,b=list(map(int,input().split()))
  if a==1:
    table[b]+=1
  if b==N:
    table2[a]+=1
for x in table:
  if x in table2:
    print("POSSIBLE")
    exit(0)
print("IMPOSSIBLE")
    

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

first = set()
second = set()
for a, b in ab:
    if a == 1:
        first.add(b)
    elif b == N:
        second.add(a)

if len(first & second):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
# Original solution
N,M = list(map(int,input().split()))

from1 = []
toN = []
for i in range(M):
  a,b = list(map(int,input().split()))
  if a ==1 or b ==1:
    from1.append(a if a!=1 else b)
  if a == N or b == N:
    toN.append(a if a!=N else b)

F = False

for i in from1:
  for j in toN:
    if i == j:
      F = True
      break
  if F:
    break
print(("POSSIBLE" if F else "IMPOSSIBLE"))

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

from1 = [False]*max(N,M)
toN = [False]*max(N,M)
for i in range(M):
  a,b = list(map(int,input().split()))
  if a ==1 or b ==1:
    from1[a-1 if a!= 1 else b-1]=True
  if a == N or b == N:
    toN[a-1 if a!= N else b-1]=True
cnt =0 
for i in range(M):
  cnt+=from1[i]&toN[i]
print(("POSSIBLE" if cnt else "IMPOSSIBLE"))
# Original solution
N,M=list(map(int,input().split()))
start=[]
end=[]
for i in range(M):
    a,b=list(map(int,input().split()))
    if a==1:
        start.append(b)
    elif b==N:
        end.append(a)

for i in start:
    if i in end:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')

# Optimized solution
N,M=list(map(int,input().split()))
start=[]
end=[]
for i in range(M):
    a,b=list(map(int,input().split()))
    if a==1:
        start.append(b)
    elif b==N:
        end.append(a)

startset=set(start)
endset=set(end)
if startset & endset:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
# Original solution
from collections import defaultdict
N, M = list(map(int, input().split()))
dep = []
arr = []
ans = "IMPOSSIBLE"

for i in range(M):
  a,b = list(map(int ,input().split()))
  if a == 1: dep.append(b-1)
  if b == N: arr.append(a-1)
 
for i in (arr):
  if i in dep:
    ans = "POSSIBLE"
    break
print(ans)

# Optimized solution
from collections import defaultdict
N, M = list(map(int, input().split()))

shima = []
ans = "IMPOSSIBLE"

for i in range(M):
  a,b = list(map(int ,input().split()))
  if a == 1: shima.append(b-1)
  if b == N: shima.append(a-1)
    
shima.sort()
for s,t in zip(shima[:-1],shima[1:]):
  if s == t:
    ans = "POSSIBLE"
    break
 
print(ans)
# Original solution
def ABC068C():
    N, M = list(map(int, input().split()))
    ship_first = []
    ship_second = []
    for _ in range(M):
        a, b = list(map(int, input().split()))
        if a == 1:
            if b == N:
                print('POSSIBLE')
                return
            else:
                ship_first.append(b)
        elif b == N:
            ship_second.append(a)

    for i in ship_first:
        if i in ship_second:
            print('POSSIBLE')
            return

    print('IMPOSSIBLE')
    return

ABC068C()


# Optimized solution
def ABC068C():
    N, M = list(map(int, input().split()))
    flag = [[False, False] for _ in range(N)]

    for _ in range(M):
        a, b = list(map(int, input().split()))
        if a == 1:
            flag[b][0] = True
        elif b == N:
            flag[a][1] = True

    for i in range(N):
        if flag[i][0] and flag[i][1]:
            print('POSSIBLE')
            return

    print('IMPOSSIBLE')
    return

ABC068C()
# Original solution

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

slink = []
glink = []

for i in range(M):

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

    if a == 1:
        slink.append(b)
    elif b == 1:
        slink.append(a)
    elif a == N:
        glink.append(b)
    elif b == N:
        glink.append(a)

ans = "IMPOSSIBLE"
for i in slink:

    if i in glink:
        ans = "POSSIBLE"
        break

print (ans)

# Optimized solution

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

slink = {}
glink = {}

for i in range(M):

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

    if a == 1:
        slink[b] = 1
    elif b == 1:
        slink[a] = 1
    elif a == N:
        glink[b] = 1
    elif b == N:
        glink[a] = 1

ans = "IMPOSSIBLE"
for i in slink:

    if i in glink:
        ans = "POSSIBLE"
        break

print (ans)
# Original solution
N, M = list(map(int, input().split()))
T = {}
for i in range(M):
    a, b = list(map(int, input().split()))
    if a not in T:
        T[a] = []
    T[a].append(b)
    if b not in T:
        T[b] = []
    T[b].append(a)
# print(N, M, T)
FROM_1 = T[1]

for f in FROM_1:
    if N in T[f]:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')


# Optimized solution
def solve():
    N, M = list(map(int, input().split()))
    T = {}
    for i in range(M):
        a, b = list(map(int, input().split()))
        if a not in T:
            T[a] = []
        T[a].append(b)
        if b not in T:
            T[b] = []
        T[b].append(a)
    # print(N, M, T)
    FROM_1 = T[1]

    for f in FROM_1:
        if N in T[f]:
            print('POSSIBLE')
            exit()
    print('IMPOSSIBLE')

if __name__ == '__main__':
    solve()
# Original solution
def solve():
    N, M = list(map(int, input().split()))
    T = {}
    for i in range(M):
        a, b = list(map(int, input().split()))
        if a not in T:
            T[a] = []
        T[a].append(b)
        if b not in T:
            T[b] = []
        T[b].append(a)
    # print(N, M, T)
    FROM_1 = T[1]

    for f in FROM_1:
        if N in T[f]:
            print('POSSIBLE')
            exit()
    print('IMPOSSIBLE')

if __name__ == '__main__':
    solve()


# Optimized solution
def solve():
    N, M = map(int, input().split())
    FROM_1 = set()
    TO_N = set()
    for i in range(M):
        a, b = map(int, input().split())
        if a == 1:
            FROM_1.add(b)
        elif a == N:
            TO_N.add(b)
        if b == 1:
            FROM_1.add(a)
        elif b == N:
            TO_N.add(a)
    ans = FROM_1 & TO_N
    print('POSSIBLE') if ans else print('IMPOSSIBLE')

if __name__ == '__main__':
    solve()
# Original solution
N, M = list(map(int, input().split()))

graph = [list() for i in range(N+1)]
for i in range(M):
    a, b = tuple(map(int, input().split()))
    graph[a].append(b)
    graph[b].append(a)

pos_flag = False
for u in graph[1]:
    if N in graph[u]:
        pos_flag = True
        break
if pos_flag == True:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

for _ in range(M):
    a, b = list(map(int, input().split()))
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
    
for g1 in graph[0]:
    if N-1 in graph[g1]:
        print("POSSIBLE")
        break
        
else:
    print("IMPOSSIBLE")
# Original solution
import sys
sys.setrecursionlimit(1000000000)
N, M = list(map(int, input().split()))
graph = [[] for _ in range(N)]
for _ in range(M):
  a, b = [int(x)-1 for x in input().split()]
  graph[a] += [b]
  graph[b] += [a]
dist = [float('inf')]*N

def dfs(u, pre, cnt):
  dist[u] = cnt
  for v in graph[u]:
    if v != pre and cnt+1 < dist[v]:
      dfs(v, u, cnt+1)

    
dfs(0, -1, 0)
if 0 < dist[N-1] <= 2:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

# Optimized solution
N, M = list(map(int, input().split()))
from_one = []
to_n = []
for _ in range(M):
  a, b = [int(x)-1 for x in input().split()]
  if a == 0:
    from_one += [b]
  elif b == 0:
    from_one += [a]
  elif a == N-1:
    to_n += [b]
  elif b == N-1:
    to_n += [a]

from_one = set(from_one)
to_n = set(to_n)
if len(from_one & to_n) >= 1:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")
# Original solution
N, M = list(map(int, input().split()))
first = []
second = []
for _ in range(M):
  a, b = list(map(int, input().split()))
  if a == 1:
    first.append(b)
  elif b == N:
    second.append(a)

ans = 0
for i in first:
  if i in second:
    ans = 1
    break
if ans:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

# Optimized solution
N, M = list(map(int, input().split()))
first = set()
second = set()
for _ in range(M):
  a, b = list(map(int, input().split()))
  if a == 1:
    first.add(b)
  elif b == N:
    second.add(a)

ans = 0
for i in first:
  if i in second:
    ans = 1
    break
if ans:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")
# Original solution
import sys
from collections import defaultdict
from collections import deque

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

graph = defaultdict(list)

for _ in range(m):
    a, b = [int(x) for x in input().split()]
    graph[a].append(b)
    graph[b].append(a)

q = deque([1])
dist = [0] * (n + 1)
dist[1] = 0

while q:
    if max(dist) > 2:
        break
    node = q.popleft()
    after = graph[node]

    for a in after:
        q.append(a)
        if a == n:
            dist[a] = dist[node] + 1
            break
        else:
            dist[a] = dist[node] + 1

print(("POSSIBLE" if dist[n] == 1 or dist[n] == 2 else "IMPOSSIBLE"))

# Optimized solution
import sys
from collections import defaultdict
from collections import deque

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

graph = defaultdict(list)

for _ in range(m):
    a, b = [int(x) for x in input().split()]
    graph[a].append(b)
    graph[b].append(a)

q = deque([1])
dist = [0] * (n + 1)
dist[1] = 0
curr = 0

while q and curr <= 2:
    node = q.popleft()
    after = graph[node]

    for a in after:
        if a == n:
            print("POSSIBLE")
            sys.exit()
        q.append(a)
        dist[a] = dist[node] + 1

    curr = dist[a]

print(("POSSIBLE" if dist[n] == 1 or dist[n] == 2 else "IMPOSSIBLE"))
# Original solution
n,m = list(map(int,input().split()))
d = {str(x):[] for x in range(1,n+1)}
n = str(n)
ans = "IMPOSSIBLE"
for i in range(m):
    t = input().split()
    d[t[0]].append(t)

for l1 in d["1"]:
    if l1[1]==n:
        ans="POSSIBLE"
    else:
        for l2 in d[l1[1]]:
            if l2[1]==n:
                ans="POSSIBLE"
print(ans)

# Optimized solution
n,m = list(map(int,input().split()))
d = {str(x):[] for x in range(1,n+1)}
n = str(n)
ans = "IMPOSSIBLE"
for i in range(m):
    t = input().split()
    d[t[0]].append(t[1])

for l1 in d["1"]:
    if l1==n:
        ans="POSSIBLE"
        break
    else:
        for l2 in d[l1]:
            if l2==n:
                ans="POSSIBLE"
                break
print(ans)
# Original solution
from collections import deque
#グラフの連結成分を調べる
def Graph(ab):
    G=[[] for i in range(n)]
    for a,b in ab:
        G[a-1].append(b)
        G[b-1].append(a)
    return G

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

for v in G[0]:
    if n in G[v - 1]:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')

# Optimized solution
#グラフの連結成分を調べる
def Graph(ab):
    G=[[] for i in range(n)]
    for a,b in ab:
        G[a-1].append(b)
        G[b-1].append(a)
    return G
n, m = list(map(int,input().split()))
ab = [list(map(int,input().split())) for i in range(m)]
G = Graph(ab)

for new_v in G[0]:
    if n in G[new_v - 1]:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')
# Original solution
import sys
def 解():
    iN,iM = [int(_) for _ in input().split()]
    aAB = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]
    dT = {}
    def addTree(dT,a,b):
        if a in dT:
            dT[a].add(b)
        else:
            dT[a] = {b}
    for a,b in aAB:
        addTree(dT,a,b)
        addTree(dT,b,a)
    if  1 not in dT or iN  not in dT:
        print("IMPOSSIBLE")
    elif 0 < len(dT[1] & dT[iN]) :
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
解()


# Optimized solution
import sys
def 解():
    iN,iM = [int(_) for _ in input().split()]
    aAB = [[int(_) for _ in sLine.split() ] for sLine in sys.stdin.readlines()]
    d1 = set()
    dN = set()
    for a,b in aAB:
        if a == 1 :
            d1.add(b)
        if b == iN:
            dN.add(a)
    if d1 & dN == set():
        print("IMPOSSIBLE")
    else:
        print("POSSIBLE")
解()
# Original solution


import sys
def 解():
    iN,iM = [int(_) for _ in input().split()]
    d1 = set()
    dN = set()
    for _ in range(iM):
        a,b = [int(_) for _ in sys.stdin.readline().split()]
        if a == 1 :
            d1.add(b)
        if b == iN:
            dN.add(a)
        if d1 & dN :
            print("POSSIBLE")
            exit()
    print("IMPOSSIBLE")
解()


# Optimized solution
import sys
def 解():
    iN,iM = [int(_) for _ in input().split()]
    a1 = [0]*iN
    aN = [0]*iN
    aAB = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]
    for a,b in aAB:
        if a == 1:
            a1[b] = 1
        if b == iN:
            aN[a] = 1
    for i in range(iN):
        if a1[i] and aN[i]:
            print("POSSIBLE")
            exit()
    print("IMPOSSIBLE")
解()
# Original solution
import sys
def 解():
    iN,iM = [int(_) for _ in input().split()]
    a1 = [0]*iN
    aN = [0]*iN
    aAB = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]
    for a,b in aAB:
        if a == 1:
            a1[b] = 1
        if b == iN:
            aN[a] = 1
    for i in range(iN):
        if a1[i] and aN[i]:
            print("POSSIBLE")
            exit()
    print("IMPOSSIBLE")
解()


# Optimized solution
import sys
input = sys.stdin.readline
def 解():
    iN,iM = [int(_) for _ in input().split()]
    a1 = [0]*iN
    aN = [0]*iN
    for i in range(iM):
        a,b = [int(_) for _ in input().split()]
        if a == 1:
            a1[b] = 1
        if b == iN:
            aN[a] = 1
    for i in range(iN):
        if a1[i] and aN[i]:
            print("POSSIBLE")
            exit()
    print("IMPOSSIBLE")
解()
# Original solution
N, M = list(map(int, input().split()))
g = {i: set() for i in range(1, N + 1)}
for _ in range(M):
    A, B = list(map(int, input().split()))
    g[A].add(B)
    g[B].add(A)

if g[1].intersection(g[N]):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


# Optimized solution
import sys


def input():
    return sys.stdin.readline().strip()


N, M = list(map(int, input().split()))
g = {i: set() for i in range(1, N + 1)}
for _ in range(M):
    A, B = list(map(int, input().split()))
    if A in (1, N) or B in (1, N):
        g[A].add(B)
        g[B].add(A)

if g[1].intersection(g[N]):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
# Original solution
import sys
N, M = list(map(int, input().split()))
routes = []
for i in range(M):
    a, b = list(map(int, input().split()))
    routes.append([a, b])
m = []
for r in routes:
    if r[0] == 1:
        m.append(r[1])
for r in routes:
    if r[0] in m:
        if r[1] == N:
            print('POSSIBLE')
            sys.exit()
print('IMPOSSIBLE')

# Optimized solution
import sys
N, M = list(map(int, input().split()))
m = set()
m2 = set()
for i in range(M):
    a, b = list(map(int, input().split()))
    if a == 1:
        m.add(b)
    if b == N:
        m2.add(a)
for me in m:
    if me in m2:
        print('POSSIBLE')
        sys.exit()
print('IMPOSSIBLE')
# Original solution
n,m=list(map(int,input().split()))
edges=[set() for i in range(n+1)]
for i in range(m):
	a,s=list(map(int,input().split()))
	edges[a].add(s)
	edges[s].add(a)
for i in range(2,n):
	if i in edges[1]&edges[n]:
		print("POSSIBLE");exit()
print("IMPOSSIBLE")

# Optimized solution
n,m=list(map(int,input().split()))
edges=[set() for i in range(n+1)]
for i in range(m):
	a,s=list(map(int,input().split()))
	edges[a].add(s)
	edges[s].add(a)
for i in range(2,n):
	if i in edges[1] and i in edges[n]:
		print("POSSIBLE");exit()
print("IMPOSSIBLE")
# Original solution
n,m = list(map(int,input().split()))
dic = {}
for i in range(m):
  a,b = list(map(int,input().split()))
  if a not in dic:
    dic[a]=[b]    
  else:    
    if b not in dic[a]:
      dic[a].append(b)      
      
  if b not in dic:
    dic[b]=[a]
    if a not in dic[b]:
      dic[b].append(a)
      
ans = 'IMPOSSIBLE'
for i in dic[1]:   
  if n in dic[i]:
    ans = 'POSSIBLE'
    break
    
print(ans)

# Optimized solution
n,m = list(map(int,input().split()))
dic = {i+1:set() for i in range(n)}
for i in range(m):
  a,b = list(map(int,input().split()))
  dic[a].add(b)
  dic[b].add(a)
        
ans = 'IMPOSSIBLE'
for i in dic[1]:   
  if n in dic[i]:
    ans = 'POSSIBLE'
    break
    
print(ans)
# Original solution
n,m=list(map(int,input().split()))
tr=[[] for i in range(n+1)]
for i in range(m):
  a,b=list(map(int,input().split()))
  if a!=1 and b!=n:
    continue
  tr[a].append(b)
  tr[b].append(a)
for i in range(2,n):
  if len(tr[i])==2:
    print("POSSIBLE")
    break
else:
  print("IMPOSSIBLE")


# Optimized solution
import sys
input=sys.stdin.readline
n,m=list(map(int,input().split()))
tr=[[] for i in range(n+1)]
for i in range(m):
  a,b=list(map(int,input().split()))
  if a!=1 and b!=n:
    continue
  tr[a].append(b)
  tr[b].append(a)
for i in range(2,n):
  if len(tr[i])==2:
    print("POSSIBLE")
    break
else:
  print("IMPOSSIBLE")