Buggy python submission (verdict: Time Limit Exceeded):
#from collections import defaultdict
from sys import stdin
input = stdin.readline

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

ans = "IMPOSSIBLE"

ls_a,ls_b = [],[]
af,bf = [False]*M,[False]*M

for m in range(M):
    a,b = map(int,(input().split()))
    if a-1 == 0:
        af[m] = True
        ls_a.append(b-1)
    if b-1 == N-1:
        bf[m] = True
        ls_b.append(a-1)
    if af[m] and bf[m]:
        ans = "POSSIBLE"
        break
    
for a in ls_a:
    if ans == "POSSIBLE":
        break
    if a in ls_b:
        ans = "POSSIBLE"
        break

print(ans)

Fixed submission:
from sys import stdin
input = stdin.readline

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

ans = "IMPOSSIBLE"

seta,setb = set(),set()
af,bf = [False]*M,[False]*M

for m in range(M):
    a,b = map(int,(input().split()))
    if a-1 == 0:
        af[m] = True
        seta.add(b-1)
    if b-1 == N-1:
        bf[m] = True
        setb.add(a-1)
    if af[m] and bf[m]:
        ans = "POSSIBLE"
        break
    
for a in seta:
    if ans == "POSSIBLE":
        break
    if a in setb:
        ans = "POSSIBLE"
        break

print(ans)

Buggy python submission (verdict: Runtime Error):
from sys import stdin
input = stdin.readline

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

ans = "IMPOSSIBLE"

ls = {}
f = [False]*M

for m in range(M):
    a,b = map(int,(input().split()))
    ls[a-1] = b-1
    
    if a-1 == 0 and b-1 == N-1:
        ans = "POSSIBLE"
    if a-1 == 0:
        f[a-1] = True

for m in range(M):
    if ans == "POSSIBLE":
        beak
    if f[m] and ls[m] in ls and  ls[ls[m]] == N-1 :
        ans = "POSSIBLE"

print(ans)

Fixed submission:
from sys import stdin
input = stdin.readline

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

ans = "IMPOSSIBLE"

seta,setb = set(),set()
af,bf = [False]*M,[False]*M

for m in range(M):
    a,b = map(int,(input().split()))
    if a-1 == 0:
        af[m] = True
        seta.add(b-1)
    if b-1 == N-1:
        bf[m] = True
        setb.add(a-1)
    if af[m] and bf[m]:
        ans = "POSSIBLE"
        break
    
for a in seta:
    if ans == "POSSIBLE":
        break
    if a in setb:
        ans = "POSSIBLE"
        break

print(ans)

Buggy python submission (verdict: Runtime Error):
from sys import stdin
input = stdin.readline

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

ans = "IMPOSSIBLE"

ls = {}
f = [False]*M

for m in range(M):
    a,b = map(int,(input().split()))
    ls[a-1] = b-1
    
    if a-1 == 0 and b-1 == N-1:
        ans = "POSSIBLE"
    if a-1 == 0:
        f[a-1] = True

for m in range(M):
    if ans == "POSSIBLE":
    if f[m] and ls[m] in ls and  ls[ls[m]] == N-1 :
        ans = "POSSIBLE"

print(ans)

Fixed submission:
from sys import stdin
input = stdin.readline

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

ans = "IMPOSSIBLE"

seta,setb = set(),set()
af,bf = [False]*M,[False]*M

for m in range(M):
    a,b = map(int,(input().split()))
    if a-1 == 0:
        af[m] = True
        seta.add(b-1)
    if b-1 == N-1:
        bf[m] = True
        setb.add(a-1)
    if af[m] and bf[m]:
        ans = "POSSIBLE"
        break
    
for a in seta:
    if ans == "POSSIBLE":
        break
    if a in setb:
        ans = "POSSIBLE"
        break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
input = stdin.readline

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

ans = "IMPOSSIBLE"

ls = [[] for m in range(M)]
for m in range(M):
    a,b = map(int,(input().split()))
    ls[m].append((a-1,b-1))
    
    if a-1 == 0 and b-1 == N-1:
        ans = "POSSIBLE"
    if a-1 == 0:
        ls[m].append("P")
    else:
        ls[m].append("I")

for m in range(M):
    if ls[m][1] == "P":
        for i in range(M):
            if ls[m][0][1] == ls[i][0][0] and ls[i][0][1] == N-1:
                ans = "POSSIBLE"

print(ans)

Fixed submission:
from sys import stdin
input = stdin.readline

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

ans = "IMPOSSIBLE"

seta,setb = set(),set()
af,bf = [False]*M,[False]*M

for m in range(M):
    a,b = map(int,(input().split()))
    if a-1 == 0:
        af[m] = True
        seta.add(b-1)
    if b-1 == N-1:
        bf[m] = True
        setb.add(a-1)
    if af[m] and bf[m]:
        ans = "POSSIBLE"
        break
    
for a in seta:
    if ans == "POSSIBLE":
        break
    if a in setb:
        ans = "POSSIBLE"
        break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,(input().split()))

ans = "IMPOSSIBLE"

ls = [[] for m in range(M)]
for m in range(M):
    a,b = map(int,(input().split()))
    ls[m].append(a-1)
    ls[m].append(b-1)
    
    if a-1 == 0 and b-1 == N-1:
        ans = "POSSIBLE"
    if a-1 == 0:
        ls[m].append("P")
    else:
        ls[m].append("I")

for m in range(M):
    if ls[m][2] == "P":
        for i in range(M):
            if ls[m][1] == ls[i][0] and ls[i][1] == N-1:
                ans = "POSSIBLE"

print(ans)

Fixed submission:
from sys import stdin
input = stdin.readline

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

ans = "IMPOSSIBLE"

seta,setb = set(),set()
af,bf = [False]*M,[False]*M

for m in range(M):
    a,b = map(int,(input().split()))
    if a-1 == 0:
        af[m] = True
        seta.add(b-1)
    if b-1 == N-1:
        bf[m] = True
        setb.add(a-1)
    if af[m] and bf[m]:
        ans = "POSSIBLE"
        break
    
for a in seta:
    if ans == "POSSIBLE":
        break
    if a in setb:
        ans = "POSSIBLE"
        break

print(ans)

Buggy python submission (verdict: Runtime Error):
N,M = map(int,(input().split()))

ans = "IMPOSSIBLE"

ls = [[] for m in range(M)]
for m in range(M):
    a,b = map(int,(input().split()))
    ls[m].append(a-1)
    ls[m].append(b-1)
    
    if a-1 == 0 and b == N-1:
        ans = "POSSIBLE"
    if a-1 == 0:
        ls[m].append("P")
    else:
        ls[m].append("I")

for m in range(M):
    if ls[m][2] == "P" and ls[ls[m][1]][1] == N-1:
        ans = "POSSIBLE"

print(ans)

Fixed submission:
from sys import stdin
input = stdin.readline

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

ans = "IMPOSSIBLE"

seta,setb = set(),set()
af,bf = [False]*M,[False]*M

for m in range(M):
    a,b = map(int,(input().split()))
    if a-1 == 0:
        af[m] = True
        seta.add(b-1)
    if b-1 == N-1:
        bf[m] = True
        setb.add(a-1)
    if af[m] and bf[m]:
        ans = "POSSIBLE"
        break
    
for a in seta:
    if ans == "POSSIBLE":
        break
    if a in setb:
        ans = "POSSIBLE"
        break

print(ans)