Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import sys

N, M = map(int, input().split())
s = []
g = []
for i in range(M):
    a, b = map(int, input().split())
    if a == 1 and b == N:
        print("POSSIBLE")
        sys.exit()
    if a == 1:
        s.append(b)
    elif b == N:
        g.append(a)

for i in s:
    if i in g:
        print("POSSIBLE")
        sys.exit()
print("IMPOSSIBLE")

Fixed submission:
# -*- coding: utf-8 -*-
import sys

N, M = map(int, input().split())
s = []
g = []
for i in range(M):
    a, b = map(int, input().split())
    if a == 1 and b == N:
        print("POSSIBLE")
        sys.exit()
    if a == 1:
        s.append(b)
    elif b == N:
        g.append(a)

if len(set(s) & set(g)) != 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import sys

N, M = map(int, input().split())
s = []
g = []
for i in range(M):
    a, b = map(int, input().split())
    if a == 1 and b == N:
        print("POSSIBLE")
        sys.exit()
    if a == 1:
        s.append(b)
    elif b == N:
        g.append(a)

for i in s:
    if i in g:
        print("POSSIBLE")
        sys.exit()
print("IMPOSSIBLE")

Fixed submission:
# -*- coding: utf-8 -*-
import sys

N, M = map(int, input().split())
s = []
g = []
for i in range(M):
    a, b = map(int, input().split())
    if a == 1 and b == N:
        print("POSSIBLE")
        sys.exit()
    if a == 1:
        s.append(b)
    elif b == N:
        g.append(a)

if len(set(s) & set(g)) != 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import sys

N, M = map(int, input().split())
NN = [[0] * N for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    NN[a-1][b-1] = 1
    NN[b-1][a-1] = 1
    if a == 1 and b == N:
        print("POSSIBLE")
        sys.exit()

for i in range(N):
    if NN[N-1][i] == 1 and NN[i][0] == 1:
        print("POSSIBLE")
        sys.exit()
print("IMPOSSIBLE")


Fixed submission:
# -*- coding: utf-8 -*-
import sys

N, M = map(int, input().split())
s = []
g = []
for i in range(M):
    a, b = map(int, input().split())
    if a == 1 and b == N:
        print("POSSIBLE")
        sys.exit()
    if a == 1:
        s.append(b)
    elif b == N:
        g.append(a)

if len(set(s) & set(g)) != 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
from scipy.sparse.csgraph import dijkstra

N, M = map(int, input().split())
NN = [[0] * N for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    NN[a-1][b-1] = 1
    NN[b-1][a-1] = 1

d = dijkstra(NN, directed = False, indices = 0)
    
if d[N-1] >= 3:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")


Fixed submission:
# -*- coding: utf-8 -*-
import sys

N, M = map(int, input().split())
s = []
g = []
for i in range(M):
    a, b = map(int, input().split())
    if a == 1 and b == N:
        print("POSSIBLE")
        sys.exit()
    if a == 1:
        s.append(b)
    elif b == N:
        g.append(a)

if len(set(s) & set(g)) != 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")