Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ship = []
for i in range(m):
    a, b = map(int, input().split())
    if a == 1 or b == n:
        ship.append((a, b))
if len(ship) == 0:
    print("IMPOSSIBLE")
    exit()

ship.sort()
i = 0

while ship[i][0] == 1:
    i += 1
    if i == len(ship):
        print("IMPOSSIBLE")
        exit()

for j in range(i):
    for k in range(i, len(ship)):
        if ship[j][1] == ship[k][0]:
            print("POSSIBLE")
            exit()
        elif ship[j][1] < ship[k][0]:
            break

print("IMPOSSIBLE")


Fixed submission:
n, m = map(int, input().split())
ship_1 = [False]*(n+1)
ship_n = [False]*(n+1)
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        ship_1[b] = True
    elif b == n:
        ship_n[a] = True

for i in range(len(ship_1)):
    if ship_1[i] and ship_n[i]:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
ship = []
for i in range(m):
    a, b = map(int, input().split())
    if a == 1 or b == n:
        ship.append((a, b))
if len(ship) == 0:
    print("IMPOSSIBLE")
    exit()

ship.sort()
i = 0

while ship[i][0] == 1:
    i += 1
if i == len(ship):
    print("IMPOSSIBLE")


for j in range(i):
    for k in range(i, len(ship)):
        if ship[j][1] == ship[k][0]:
            print("POSSIBLE")
            exit()
        elif ship[j][1] < ship[k][0]:
            break

print("IMPOSSIBLE")


Fixed submission:
n, m = map(int, input().split())
ship_1 = [False]*(n+1)
ship_n = [False]*(n+1)
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        ship_1[b] = True
    elif b == n:
        ship_n[a] = True

for i in range(len(ship_1)):
    if ship_1[i] and ship_n[i]:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
ship = []
for i in range(m):
    a, b = map(int, input().split())
    if a == 1 or b == n:
        ship.append((a, b))
if len(ship) == 0:
    print("IMPOSSIBLE")
    exit()

ship.sort()
i = 0

while ship[i][0] == 1:
    i += 1
if i == len(ship):
    print("IMPOSSIBLE")
    

for j in range(i):
    for k in range(i, len(ship)):
        if ship[j][1] == ship[k][0]:
            print("POSSIBLE")
            exit()
        elif ship[j][1] < ship[k][0]
            break

print("IMPOSSIBLE")


Fixed submission:
n, m = map(int, input().split())
ship_1 = [False]*(n+1)
ship_n = [False]*(n+1)
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        ship_1[b] = True
    elif b == n:
        ship_n[a] = True

for i in range(len(ship_1)):
    if ship_1[i] and ship_n[i]:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
ship = []
for i in range(m):
    a, b = map(int, input().split())
    if a == 1 or b == n:
        ship.append((a, b))
if len(ship) == 0:
    print("IMPOSSIBLE")
    exit()
    
ship.sort()
i = 0

while ship[i][0] == 1:
    i += 1

for j in range(i):
    for k in range(i, len(ship)):
        if ship[j][1] == ship[k][0]:
            print("POSSIBLE")
            exit()
        elif ship[j][1] < ship[k][0]
            break

print("IMPOSSIBLE")


Fixed submission:
n, m = map(int, input().split())
ship_1 = [False]*(n+1)
ship_n = [False]*(n+1)
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        ship_1[b] = True
    elif b == n:
        ship_n[a] = True

for i in range(len(ship_1)):
    if ship_1[i] and ship_n[i]:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
ship = []
for i in range(m):
    a, b = map(int, input().split())
    if a == 1 or b == n:
        ship.append((a, b))

ship.sort()
i = 0

while ship[i][0] == 1:
    i += 1

for j in range(i):
    for k in range(i, len(ship)):
        if ship[j][1] == ship[k][0]:
            print("POSSIBLE")
            exit()

print("IMPOSSIBLE")


Fixed submission:
n, m = map(int, input().split())
ship_1 = [False]*(n+1)
ship_n = [False]*(n+1)
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        ship_1[b] = True
    elif b == n:
        ship_n[a] = True

for i in range(len(ship_1)):
    if ship_1[i] and ship_n[i]:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
ship = []
for i in range(m):
    a, b = map(int, input().split())
    if a == 1 or b == n:
        ship.append((a, b))

ship.sort()
print(ship)
i = 0

while ship[i][0] == 1:
    i += 1

for j in range(i):
    for k in range(i, len(ship)):
        if ship[j][1] == ship[k][0]:
            print("POSSIBLE")
            exit()

print("IMPOSSIBLE")


Fixed submission:
n, m = map(int, input().split())
ship_1 = [False]*(n+1)
ship_n = [False]*(n+1)
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        ship_1[b] = True
    elif b == n:
        ship_n[a] = True

for i in range(len(ship_1)):
    if ship_1[i] and ship_n[i]:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
ship = []
for i in range(m):
    a, b = map(int, input().split())
    if a == 1 or b == n:
        ship.append((a, b))

ship.sort()
i = 0

while ship[i][0] == 1:
    i += 1

for j in range(i):
    for k in range(i, m):
        if ship[j][1] == ship[k][0]:
            print("POSSIBLE")
            exit()

print("IMPOSSIBLE")


Fixed submission:
n, m = map(int, input().split())
ship_1 = [False]*(n+1)
ship_n = [False]*(n+1)
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        ship_1[b] = True
    elif b == n:
        ship_n[a] = True

for i in range(len(ship_1)):
    if ship_1[i] and ship_n[i]:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
ship = []
for i in range(m):
    a, b = map(int, input().split())
    if a == 1 or b == n:
        ship.append((a, b))

ship.sort()
i = 0

while ship[i][0] == 1:
    i += 1

for j in range(i):
    for k in range(i+1, m):
        if ship[j][1] == ship[k][0]:
            print("POSSIBLE")
            exit()

print("IMPOSSIBLE")


Fixed submission:
n, m = map(int, input().split())
ship_1 = [False]*(n+1)
ship_n = [False]*(n+1)
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        ship_1[b] = True
    elif b == n:
        ship_n[a] = True

for i in range(len(ship_1)):
    if ship_1[i] and ship_n[i]:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
ship = []
for i in range(m):
    ship.append(tuple(map(int, input().split())))

ship.sort()
for s in ship:
    if s[0] != 1 and s[1] != n:
        ship.remove(s)

i = 0

while ship[i][0] == 1:
    i += 1

for j in range(i):
    for k in range(i+1, m):
        if ship[j][1] == ship[k][0]:
            print("POSSIBLE")
            exit()

print("IMPOSSIBLE")


Fixed submission:
n, m = map(int, input().split())
ship_1 = [False]*(n+1)
ship_n = [False]*(n+1)
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        ship_1[b] = True
    elif b == n:
        ship_n[a] = True

for i in range(len(ship_1)):
    if ship_1[i] and ship_n[i]:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
ship = []
for i in range(m):
    ship.append(tuple(map(int, input().split())))

ship.sort()
for s in ship:
    if s[0] != 1 and s[1] != n:
        ship.remove(s)

i = 0

while ship[i][0]:
    i += 1

for j in range(i):
    for k in range(i+1, m):
        if ship[j][1] == ship[k][0]:
            print("POSSIBLE")
            exit()

print("IMPOSSIBLE")


Fixed submission:
n, m = map(int, input().split())
ship_1 = [False]*(n+1)
ship_n = [False]*(n+1)
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        ship_1[b] = True
    elif b == n:
        ship_n[a] = True

for i in range(len(ship_1)):
    if ship_1[i] and ship_n[i]:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

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

for i in range(m):
    if ship[i][0] == 1:
        for j in range(m):
            if ship[i][1] == ship[j][0] and ship[j][1] == n or ship[i][1] == ship[j][1] and ship[j][0] == n:
                print("POSSIBLE")
                exit()
    elif ship[i][1] == 1:
        for j in range(m):
            if ship[i][0] == ship[j][0] and ship[j][1] == n or ship[i][0] == ship[j][1] and ship[j][0] == n:
                print("POSSIBLE")
                exit()

print("IMPOSSIBLE")


Fixed submission:
n, m = map(int, input().split())
ship_1 = [False]*(n+1)
ship_n = [False]*(n+1)
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        ship_1[b] = True
    elif b == n:
        ship_n[a] = True

for i in range(len(ship_1)):
    if ship_1[i] and ship_n[i]:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
ship = []
for i in range(m):
    ship[i] = tuple(map(int, input().split()))

for i in range(m):
    if ship[i][0] == 1:
        for j in range(i+1, m):
            if ship[i][1] == ship[j][0] and ship[j][1] == n or ship[i][1] == ship[j][1] and ship[j][0] == n:
                print("POSSIBLE")
                exit()
    elif ship[i][1] == 1:
        for j in range(i+1, m):
            if ship[i][0] == ship[j][0] and ship[j][1] == n or ship[i][0] == ship[j][1] and ship[j][0] == n:
                print("POSSIBLE")
                exit()

print("IMPOSSIBLE")


Fixed submission:
n, m = map(int, input().split())
ship_1 = [False]*(n+1)
ship_n = [False]*(n+1)
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        ship_1[b] = True
    elif b == n:
        ship_n[a] = True

for i in range(len(ship_1)):
    if ship_1[i] and ship_n[i]:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")