Buggy python submission (verdict: Time Limit Exceeded):
import sys
n,m=map(int,input().split())
a = [[int(i) for i in input().split()] for i in range(m)] 
c=[]

a = sorted(a,key = lambda x:-x[1])

#print(a[0][0],a[0][1])
for i in range(m):
    if a[i][1] < n:
        break
    else:
        c.append(a[i][0])

a = sorted(a,key = lambda x:x[0])
for i in range(m):
    if a[i][0] > 1:
        break
    if a[i][1] in c:
            print("POSSIBLE")
            sys.exit()
        
print("IMPOSSIBLE")


Fixed submission:
import sys
n,m=map(int,input().split())
a = [[int(i) for i in input().split()] for i in range(m)] 
c=[]
s=[]
a = sorted(a,key = lambda x:-x[1])

#print(a[0][0],a[0][1])
for i in range(m):
    if a[i][1] < n:
        break
    else:
        c.append(a[i][0])
c=set(c)
a = sorted(a,key = lambda x:x[0])
for i in range(m):
    if a[i][0] > 1:
        break
    else:
        s.append(a[i][1])

    #if a[i][1] in c:
s=set(s)

for i in s:
    if i in c:
        print("POSSIBLE")
        sys.exit()

print("IMPOSSIBLE")

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

a = sorted(li,key = lambda x:-x[1])


for i in range(m):
    if a[i][1] < n:
        break
    else:
        c.append(a[i][0])

a = sorted(li,key = lambda x:x[0])
for i in range(m):
    if a[i][0] > 1:
        break
    if a[i][1] in c:
            print("POSSIBLE")
            sys.exit()
        
print("IMPOSSIBLE")


Fixed submission:
import sys
n,m=map(int,input().split())
a = [[int(i) for i in input().split()] for i in range(m)] 
c=[]
s=[]
a = sorted(a,key = lambda x:-x[1])

#print(a[0][0],a[0][1])
for i in range(m):
    if a[i][1] < n:
        break
    else:
        c.append(a[i][0])
c=set(c)
a = sorted(a,key = lambda x:x[0])
for i in range(m):
    if a[i][0] > 1:
        break
    else:
        s.append(a[i][1])

    #if a[i][1] in c:
s=set(s)

for i in s:
    if i in c:
        print("POSSIBLE")
        sys.exit()

print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
import sys

n,m=map(int,input().split())
a = [[int(i) for i in input().split()] for i in range(m)] 
c=[]

#print(a[0][0],a[0][1])
for i in range(m):
    if a[i][1] == n:
        c.append(a[i][0])
for i in range(m):
    if a[i][0]==1:
        if a[i][1] in c:
            print("POSSIBLE")
            sys.exit()
        
print("IMPOSSIBLE")


Fixed submission:
import sys
n,m=map(int,input().split())
a = [[int(i) for i in input().split()] for i in range(m)] 
c=[]
s=[]
a = sorted(a,key = lambda x:-x[1])

#print(a[0][0],a[0][1])
for i in range(m):
    if a[i][1] < n:
        break
    else:
        c.append(a[i][0])
c=set(c)
a = sorted(a,key = lambda x:x[0])
for i in range(m):
    if a[i][0] > 1:
        break
    else:
        s.append(a[i][1])

    #if a[i][1] in c:
s=set(s)

for i in s:
    if i in c:
        print("POSSIBLE")
        sys.exit()

print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
import sys

n,m=map(int,input().split())
a = [[int(i) for i in input().split()] for i in range(m)] 
c=[]

#print(a[0][0],a[0][1])
for i in range(m):
    if a[i][1] == n:
        c.append(a[i][0])
for i in range(m):
    if a[i][0]==1:
        if a[i][1] in c:
            print("POSSIBLE")
            sys.exit()
        
print("IMPOSSIBLE")


Fixed submission:
import sys
n,m=map(int,input().split())
a = [[int(i) for i in input().split()] for i in range(m)] 
c=[]
s=[]
a = sorted(a,key = lambda x:-x[1])

#print(a[0][0],a[0][1])
for i in range(m):
    if a[i][1] < n:
        break
    else:
        c.append(a[i][0])
c=set(c)
a = sorted(a,key = lambda x:x[0])
for i in range(m):
    if a[i][0] > 1:
        break
    else:
        s.append(a[i][1])

    #if a[i][1] in c:
s=set(s)

for i in s:
    if i in c:
        print("POSSIBLE")
        sys.exit()

print("IMPOSSIBLE")