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

toN = list(filter(lambda x: N in x, AB))
toN = [flatten for inner in toN for flatten in inner]
frm_first = list(filter(lambda x: 1 in x, AB))
frm_first = [flatten for inner in frm_first for flatten in inner]

for v in frm_first:
    if v in toN:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")

Fixed submission:
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(M)]

toN = list(filter(lambda x: N in x, AB))
toN = set([flatten for inner in toN for flatten in inner])
frm_first = list(filter(lambda x: 1 in x, AB))
frm_first = set([flatten for inner in frm_first for flatten in inner])

if toN & frm_first:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
import sys

N , M = map(int , input().split())
voyages = []
for i in range(M):
    voyages.append(list(map(int , input().split())))

def search(goal, path):
    n = path[len(path) - 1]
    if n == goal - 1:
        if len(path) < 4:
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")
        sys.exit()
        
    else:
        if n < len(voyages):
            for x in voyages[n]:
                if x not in path:
                    path.append(x)
                    search(goal, path)
                    path.pop()
        else:
            print("IMPOSSIBLE")
            sys.exit()
            
search(N, [0])

Fixed submission:
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(M)]

toN = list(filter(lambda x: N in x, AB))
toN = set([flatten for inner in toN for flatten in inner])
frm_first = list(filter(lambda x: 1 in x, AB))
frm_first = set([flatten for inner in frm_first for flatten in inner])

if toN & frm_first:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
import sys

N , M = map(int , input().split())
voyages = []
for i in range(M):
    voyages.append(list(map(int , input().split())))

def search(goal, path):
    n = path[len(path) - 1]
    if n == goal - 1:
        if len(path) < 4:
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")
        sys.exit()
        
    else:
        if n <= len(voyages):
            for x in voyages[n]:
                if x not in path:
                    path.append(x)
                    search(goal, path)
                    path.pop()
        else:
            print("IMPOSSIBLE")
            sys.exit()
            

if len(voyages) == 1:
    if not (N in voyages[0]):
        print("IMPOSSIBLE")
else:
    search(N, [0])

Fixed submission:
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(M)]

toN = list(filter(lambda x: N in x, AB))
toN = set([flatten for inner in toN for flatten in inner])
frm_first = list(filter(lambda x: 1 in x, AB))
frm_first = set([flatten for inner in frm_first for flatten in inner])

if toN & frm_first:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
import sys

N , M = map(int , input().split())
voyages = []
for i in range(M):
    voyages.append(list(map(int , input().split())))

def search(goal, path):
    n = path[len(path) - 1]
    if n == goal - 1:
        if len(path) < 4:
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")
        sys.exit()
        
    else:
        for x in voyages[n]:
            if x not in path:
                path.append(x)
                search(goal, path)
                path.pop()

if len(voyages) == 1:
    if not (N in voyages[0]):
        print("IMPOSSIBLE")
else:
    search(N, [0])

Fixed submission:
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(M)]

toN = list(filter(lambda x: N in x, AB))
toN = set([flatten for inner in toN for flatten in inner])
frm_first = list(filter(lambda x: 1 in x, AB))
frm_first = set([flatten for inner in frm_first for flatten in inner])

if toN & frm_first:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")