Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = []
tmp = []
for i in range(M):
    tmp = list(map(str,input().split()))
    a.append(list(tmp))

siCheck = [0 for i in range(N)]
inCheck = [0 for i in range(N)]

for i in range(N):
    if a[i][0] == '1':
        siCheck[int(a[i][1])-1] = True
    else:
        siCheck[int(a[i][1])-1] = False
    if int(a[i][1]) == N:
        inCheck[int(a[i][0])-1] = True
    else:
        inCheck[int(a[i][0])-1] = False

for i in range(N):
    if siCheck[i] and inCheck[i]:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')

Fixed submission:
from collections import deque

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

island_map = {}
for a,b in route:
    if a not in island_map:
        island_map[a] = [b]
    else:
        island_map[a].append(b)

first_island = deque()
first_island += island_map[1]
second_island = deque()

for i in first_island:
    if i in island_map:
        second_island += island_map[i]
    else:
        pass
    for j in second_island:
        if j == N:
            print('POSSIBLE')
            exit()

print('IMPOSSIBLE')

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = []
tmp = []
for i in range(M):
    tmp = list(map(str,input().split()))
    a.append(list(tmp))

siCheck = [0 for i in range(N)]
inCheck = [0 for i in range(N)]

for i in range(M):
    if a[i][0] == '1':
        siCheck[int(a[i][1])-1] = True
    else:
        siCheck[int(a[i][1])-1] = False
    if int(a[i][1]) == N:
        inCheck[int(a[i][0])-1] = True
    else:
        inCheck[int(a[i][0])-1] = False

for i in range(M):
    if siCheck[i] and inCheck[i]:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')

Fixed submission:
from collections import deque

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

island_map = {}
for a,b in route:
    if a not in island_map:
        island_map[a] = [b]
    else:
        island_map[a].append(b)

first_island = deque()
first_island += island_map[1]
second_island = deque()

for i in first_island:
    if i in island_map:
        second_island += island_map[i]
    else:
        pass
    for j in second_island:
        if j == N:
            print('POSSIBLE')
            exit()

print('IMPOSSIBLE')

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = []
tmp = []
for i in range(M):
    tmp = list(map(str,input().split()))
    a.append(list(tmp))

siCheck = [0 for i in range(N)]
inCheck = [0 for i in range(N)]

for i in range(M):
    if a[i][0] == '1':
        siCheck[int(a[i][1])-1] = True
    else:
        siCheck[int(a[i][1])-1] = False
    if int(a[i][1]) == N:
        inCheck[int(a[i][0])-1] = True
    else:
        inCheck[int(a[i][0])-1] = False

for i in range(M):
    if siCheck[i] and inCheck[i]:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')

Fixed submission:
from collections import deque

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

island_map = {}
for a,b in route:
    if a not in island_map:
        island_map[a] = [b]
    else:
        island_map[a].append(b)

first_island = deque()
first_island += island_map[1]
second_island = deque()

for i in first_island:
    if i in island_map:
        second_island += island_map[i]
    else:
        pass
    for j in second_island:
        if j == N:
            print('POSSIBLE')
            exit()

print('IMPOSSIBLE')

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
a = []
tmp = []
for i in range(M):
    tmp = list(map(str,input().split()))
    a.append(list(tmp))

startCheck = False
startST = []

for i in a:
    if i[0] == '1':
        startCheck = True
        startST.append(i[1])

if not startCheck:
    print('IMPOSSIBLE')
    exit()

for i in a:
    if i[0] in startST:
        if int(i[1]) == N:
            print('POSSIBLE')
            exit()

print('IMPOSSIBLE')

Fixed submission:
from collections import deque

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

island_map = {}
for a,b in route:
    if a not in island_map:
        island_map[a] = [b]
    else:
        island_map[a].append(b)

first_island = deque()
first_island += island_map[1]
second_island = deque()

for i in first_island:
    if i in island_map:
        second_island += island_map[i]
    else:
        pass
    for j in second_island:
        if j == N:
            print('POSSIBLE')
            exit()

print('IMPOSSIBLE')