Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ships = [[int(x) for x in input().split()] for x in range(m)]

judge = False
relay = []
goal = []

for ship in ships:
    if n in ship:
        goal.append(ship[0])
    elif 1 in ship:
        relay.append(ship[1])

res = False
if len(goal) == 0 or len(relay) == 0:
    print("IMPOSSIBLE")
else:
    for i in relay:
        if i in goal:
            res = True
            break
    print("POSSIBLE" if res else "IMPOSSIBLE")

Fixed submission:
n, m = map(int, input().split())
ships = [[int(x) for x in input().split()] for x in range(m)]

judge = False
relay = []
goal = []

for ship in ships:
    if n in ship:
        goal.append(ship[0])
    elif 1 in ship:
        relay.append(ship[1])

res = False
if len(goal) == 0 or len(relay) == 0:
    print("IMPOSSIBLE")

else:
    print("IMPOSSIBLE" if not set(relay) & set(goal) else "POSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ships = [[int(x) for x in input().split()] for x in range(m)]

judge = False
relay = []
for ship in ships:
    if n in ship:
        judge = True
        relay.append(ship[0])

res = False
if judge is False:
    print("IMPOSSIBLE")
else:
    for i in relay:
        if [1, i] in ships:
            res = True
            break
    print("POSSIBLE" if res else "IMPOSSIBLE")

Fixed submission:
n, m = map(int, input().split())
ships = [[int(x) for x in input().split()] for x in range(m)]

judge = False
relay = []
goal = []

for ship in ships:
    if n in ship:
        goal.append(ship[0])
    elif 1 in ship:
        relay.append(ship[1])

res = False
if len(goal) == 0 or len(relay) == 0:
    print("IMPOSSIBLE")

else:
    print("IMPOSSIBLE" if not set(relay) & set(goal) else "POSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ships = [[int(x) for x in input().split()] for x in range(m)]

judge = False
relay = []
for ship in ships:
    if n in ship:
        judge = True
        relay.append(ship[0])

res = False
if judge is False:
    print("IMPOSSIBLE")
else:
    for i in relay:
        if [1, i] in ships:
            res = True
    print("POSSIBLE" if res else "IMPOSSIBLE")

Fixed submission:
n, m = map(int, input().split())
ships = [[int(x) for x in input().split()] for x in range(m)]

judge = False
relay = []
goal = []

for ship in ships:
    if n in ship:
        goal.append(ship[0])
    elif 1 in ship:
        relay.append(ship[1])

res = False
if len(goal) == 0 or len(relay) == 0:
    print("IMPOSSIBLE")

else:
    print("IMPOSSIBLE" if not set(relay) & set(goal) else "POSSIBLE")

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

array = []
for i in range(m):
    tmp = sorted([int(x) for x in input().split()])
    array.append(tmp)

determination = []
for j in range(len(array)):
    if array[j][0] == 1:
        determination.append(array[j][1])

res = False
for k in determination:
    for l in array:
        if k in l and n in l:
            res = True
            break
    if res:
        break
print("POSSIBLE" if res else "IMPOSSIBLE")

Fixed submission:
n, m = map(int, input().split())
ships = [[int(x) for x in input().split()] for x in range(m)]

judge = False
relay = []
goal = []

for ship in ships:
    if n in ship:
        goal.append(ship[0])
    elif 1 in ship:
        relay.append(ship[1])

res = False
if len(goal) == 0 or len(relay) == 0:
    print("IMPOSSIBLE")

else:
    print("IMPOSSIBLE" if not set(relay) & set(goal) else "POSSIBLE")