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

n,m = [int(x) for x in stdin.readline().rstrip().split()]

inf = 10**10

def warshall_floyd(d):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

d = [[inf for i in range(n)] for i in range(n)] 

for i in range(m):
    x,y = [int(x) for x in stdin.readline().rstrip().split()]
    d[x-1][y-1] = 1
    d[y-1][x-1] = 1
for i in range(n):
    d[i][i] = 0

li = warshall_floyd(d)

if li[0][n-1] == 2:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Fixed submission:
from sys import stdin

n,m = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]

lin = [0]*n

for i in li:
    if i[0] == 1:
        lin[i[1]-1] += 1
    if i[1] == n:
        lin[i[0]-1] += 1

for i in lin:
    if i == 2:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

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

n,m = [int(x) for x in stdin.readline().rstrip().split()]

inf = 10**10

def warshall_floyd(d):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

d = [[inf for i in range(n)] for i in range(n)] 

for i in range(m):
    x,y = [int(x) for x in stdin.readline().rstrip().split()]
    d[x-1][y-1] = 1
    d[y-1][x-1] = 1
for i in range(n):
    d[i][i] = 0

li = warshall_floyd(d)

if li[0][n-1] == 2:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Fixed submission:
from sys import stdin

n,m = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]

lin = [0]*n

for i in li:
    if i[0] == 1:
        lin[i[1]-1] += 1
    if i[1] == n:
        lin[i[0]-1] += 1

for i in lin:
    if i == 2:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

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

n,m = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]

li.sort()

mi = []
ma = []

for i in li:
    if i[0] == 1:
        mi.append(i[1])
    if i[1] == n:
        ma.append(i[0])

for s in mi:
    for k in ma:
        if s == k:
            print("POSSIBLE")
            exit()

print("IMPOSSIBLE")

Fixed submission:
from sys import stdin

n,m = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]

lin = [0]*n

for i in li:
    if i[0] == 1:
        lin[i[1]-1] += 1
    if i[1] == n:
        lin[i[0]-1] += 1

for i in lin:
    if i == 2:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

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

n,m = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]
li.sort()

lin = []

for i in li:
    if i[1] == n:
        lin.append(i[0])
for j in li:
    for k in lin:
        if j == [1,k]:
            print("POSSIBLE")
            exit()

print("IMPOSSIBLE")

Fixed submission:
from sys import stdin

n,m = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]

lin = [0]*n

for i in li:
    if i[0] == 1:
        lin[i[1]-1] += 1
    if i[1] == n:
        lin[i[0]-1] += 1

for i in lin:
    if i == 2:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

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

n,m = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]

lin = []

for i in li:
    if i[1] == n:
        lin.append(i[0])
for j in lin:
    if [1,j] in li:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

Fixed submission:
from sys import stdin

n,m = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]

lin = [0]*n

for i in li:
    if i[0] == 1:
        lin[i[1]-1] += 1
    if i[1] == n:
        lin[i[0]-1] += 1

for i in lin:
    if i == 2:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")