Buggy python submission (verdict: Time Limit Exceeded):
A = 0
B = 1
mid = []
goalIndex = []
ab = []

n, m = map(int, input().split())
for i in range(m):
    a,b = map(int, input().split())
    ab.append([a, b])
    if a == 1:
        mid.append(b)
    elif b == n:
        goalIndex.append(i)

# for _ab in ab:
#     if _ab[B] == n and _ab[A] in mid:
#         print("POSSIBLE")
#         exit()

for m in mid:
    for g in goalIndex:
        if ab[g][A] == m:
            print("POSSIBLE")
            exit()            

print("IMPOSSIBLE")

Fixed submission:
n, m = map(int, input().split())

A = 0
B = 1
mid = [0] * (n+1)
goal = [0] * (n+1)
ab = []

for i in range(m):
    a,b = map(int, input().split())
    ab.append([a, b])
    if a == 1:
        mid[b] += 1
    elif b == n:
        goal[a] += 1

# print(mid)
# print(goal)

for i in range(n+1):
    if mid[i] == 1 and goal[i] == 1:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
A = 0
B = 1
mid = []
ab = []

n, m = map(int, input().split())
for i in range(m):
    a,b = map(int, input().split())
    if a == 1:
        mid.append(b)
    else:
        ab.append([a, b])

for _ab in ab:
    if _ab[B] == n and _ab[A] in mid:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

Fixed submission:
n, m = map(int, input().split())

A = 0
B = 1
mid = [0] * (n+1)
goal = [0] * (n+1)
ab = []

for i in range(m):
    a,b = map(int, input().split())
    ab.append([a, b])
    if a == 1:
        mid[b] += 1
    elif b == n:
        goal[a] += 1

# print(mid)
# print(goal)

for i in range(n+1):
    if mid[i] == 1 and goal[i] == 1:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
a = 0
b = 1
mid = []
ab = []

n, m = map(int, input().split())
for i in range(m):
    ab.append(list(map(int, input().split())))
    if ab[i][a] == 1:
        mid.append(ab[i][b])

# print(mid)

for _ab in ab:
    if _ab[b] == n and _ab[a] in mid:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

Fixed submission:
n, m = map(int, input().split())

A = 0
B = 1
mid = [0] * (n+1)
goal = [0] * (n+1)
ab = []

for i in range(m):
    a,b = map(int, input().split())
    ab.append([a, b])
    if a == 1:
        mid[b] += 1
    elif b == n:
        goal[a] += 1

# print(mid)
# print(goal)

for i in range(n+1):
    if mid[i] == 1 and goal[i] == 1:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
a = 0
b = 1
mid = []
ab = []

n, m = map(int, input().split())
for i in range(m):
    ab.append(list(map(int, input().split())))
    if ab[i][a] == 1:
        mid.append(ab[i][b])

# print(mid)

for _ab in ab:
    if _ab[b] == n and _ab[a] in mid:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

Fixed submission:
n, m = map(int, input().split())

A = 0
B = 1
mid = [0] * (n+1)
goal = [0] * (n+1)
ab = []

for i in range(m):
    a,b = map(int, input().split())
    ab.append([a, b])
    if a == 1:
        mid[b] += 1
    elif b == n:
        goal[a] += 1

# print(mid)
# print(goal)

for i in range(n+1):
    if mid[i] == 1 and goal[i] == 1:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")