Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
ans = 'IMPOSSIBLE'
abl1 = []
abl2 = []
for _ in range(M):
    ab = list(map(int,input().split()))
    if ab[0] == 1:
        abl1.append(ab)
    elif ab[1] == N:
        abl2.append(ab)
    for i in abl1:
        if [i[1], N] in abl2:
            ans = 'POSSIBLE'
print(ans)

Fixed submission:
N, M = map(int, input().split())

abl1 = set()
abl2 = set()
for _ in range(M):
    ab = list(map(int,input().split()))
    if ab[0] == 1:
        abl1.add(ab[1])
    elif ab[1] == N:
        abl2.add(ab[0])


for i in abl1:
   if i in abl2:
       print("POSSIBLE")
       exit()
print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
abl1 = []
abl2 = []
for _ in range(M):
    ab = list(map(int,input().split()))
    if ab[0] == 1:
        abl1.append(ab)
    elif ab[1] == N:
        abl2.append(ab)

for i in abl1:
    if [i[1], N] in abl2:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')


Fixed submission:
N, M = map(int, input().split())

abl1 = set()
abl2 = set()
for _ in range(M):
    ab = list(map(int,input().split()))
    if ab[0] == 1:
        abl1.add(ab[1])
    elif ab[1] == N:
        abl2.add(ab[0])


for i in abl1:
   if i in abl2:
       print("POSSIBLE")
       exit()
print("IMPOSSIBLE")

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

ans = 'IMPOSSIBLE'
for i in abl:
    if i[0] == 1 and [i[1],N] in abl:
        ans = 'POSSIBLE'
        print(ans)
        exit()
print(ans)


Fixed submission:
N, M = map(int, input().split())

abl1 = set()
abl2 = set()
for _ in range(M):
    ab = list(map(int,input().split()))
    if ab[0] == 1:
        abl1.add(ab[1])
    elif ab[1] == N:
        abl2.add(ab[0])


for i in abl1:
   if i in abl2:
       print("POSSIBLE")
       exit()
print("IMPOSSIBLE")

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

island = 0
ans = 'IMPOSSIBLE'
for i in abl:
    if i[0] == 1:
        island = i[1]
    if [island,N] in abl:
        ans = 'POSSIBLE'
        print(ans)
        exit()
print(ans)


Fixed submission:
N, M = map(int, input().split())

abl1 = set()
abl2 = set()
for _ in range(M):
    ab = list(map(int,input().split()))
    if ab[0] == 1:
        abl1.add(ab[1])
    elif ab[1] == N:
        abl2.add(ab[0])


for i in abl1:
   if i in abl2:
       print("POSSIBLE")
       exit()
print("IMPOSSIBLE")

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

island = 0
ans = 'IMPOSSIBLE'
for i in abl:
    if i[0] == 1:
        island = i[1]
        for v in abl:
            if v[0] == island and v[1] == N:
                ans = 'POSSIBLE'
                print(ans)
                exit()

print(ans)


Fixed submission:
N, M = map(int, input().split())

abl1 = set()
abl2 = set()
for _ in range(M):
    ab = list(map(int,input().split()))
    if ab[0] == 1:
        abl1.add(ab[1])
    elif ab[1] == N:
        abl2.add(ab[0])


for i in abl1:
   if i in abl2:
       print("POSSIBLE")
       exit()
print("IMPOSSIBLE")

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

counter = 0
island = 0
ans = 'IMPOSSIBLE'
for i in abl:
    if i[0] == 1:
        island = i[1]
        counter += 1
        for j in abl:
            if j[0] == island and j[1] == N:
                ans = 'POSSIBLE'
                print(ans)
                exit()

print(ans)


Fixed submission:
N, M = map(int, input().split())

abl1 = set()
abl2 = set()
for _ in range(M):
    ab = list(map(int,input().split()))
    if ab[0] == 1:
        abl1.add(ab[1])
    elif ab[1] == N:
        abl2.add(ab[0])


for i in abl1:
   if i in abl2:
       print("POSSIBLE")
       exit()
print("IMPOSSIBLE")