Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
info = sorted([list(map(int, input().split())) for _ in range(m)])

q = []
t = m
append = q.append
for i in range(m):
	if info[i][0] == 1:
		append(info[i][1])
	else:
		t = i
		break

for j in range(t, m):
	if info[j][1] == n:
		if info[j][0] in q:
			print("POSSIBLE")
			break
else:
	print("IMPOSSIBLE")

Fixed submission:
n, m = map(int, input().split())
side1 = set()
side2 = set()

for i in range(m):
	a, b = map(int, input().split())

	if a == 1:
		side1.add(b)
	
	elif b == n:
		side2.add(a)

print(("" if side1 & side2 else "IM") + "POSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
info = sorted([list(map(int, input().split())) for _ in range(m)])

q = []
t = m
for i in range(m):
	if info[i][0] == 1:
		q.append(info[i][1])
	else:
		t = i
		break

for j in range(t, m):
	if info[j][0] in q:
		if info[j][1] == n:
			print("POSSIBLE")
			break
else:
	print("IMPOSSIBLE")

Fixed submission:
n, m = map(int, input().split())
side1 = set()
side2 = set()

for i in range(m):
	a, b = map(int, input().split())

	if a == 1:
		side1.add(b)
	
	elif b == n:
		side2.add(a)

print(("" if side1 & side2 else "IM") + "POSSIBLE")

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
info = sorted([list(map(int, input().split())) for _ in range(m)])

q = []
for i in range(m):
	if info[i][0] == 1:
		q.append(info[i][1])
	else:
		t = i
		break

for j in range(t, m):
	if info[j][0] in q:
		if info[j][1] == n:
			print("POSSIBLE")
			break
else:
	print("IMPOSSIBLE")

Fixed submission:
n, m = map(int, input().split())
side1 = set()
side2 = set()

for i in range(m):
	a, b = map(int, input().split())

	if a == 1:
		side1.add(b)
	
	elif b == n:
		side2.add(a)

print(("" if side1 & side2 else "IM") + "POSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
info = sorted([list(map(int, input().split())) for _ in range(m)])

q = []
for r in info:
	if r[0] == 1:
		q.append(r[1])

	elif (r[0] in q) and r[1] == n:
		print("POSSIBLE")
		break
else:
	print("IMPOSSIBLE")

Fixed submission:
n, m = map(int, input().split())
side1 = set()
side2 = set()

for i in range(m):
	a, b = map(int, input().split())

	if a == 1:
		side1.add(b)
	
	elif b == n:
		side2.add(a)

print(("" if side1 & side2 else "IM") + "POSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
info = sorted([list(map(int, input().split())) for _ in range(m)])

q = []
for r in info:
	if r[0] == 1:
		q.append(r[1])

	elif (r[0] in q) and r[1] == n:
		print("POSSIBLE")
		break
else:
	print("IMPOSSIBLE")

Fixed submission:
n, m = map(int, input().split())
side1 = set()
side2 = set()

for i in range(m):
	a, b = map(int, input().split())

	if a == 1:
		side1.add(b)
	
	elif b == n:
		side2.add(a)

print(("" if side1 & side2 else "IM") + "POSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
info = [list(map(int, input().split())) for _ in range(m)]
info = sorted(info, key=lambda x: x[0])

q = []
for r in info:
	if r[0] == 1:
		q.append(r[1])
		continue

	elif (r[0] in q) and r[1] == n:
		print("POSSIBLE")
		break
else:
	print("IMPOSSIBLE")

Fixed submission:
n, m = map(int, input().split())
side1 = set()
side2 = set()

for i in range(m):
	a, b = map(int, input().split())

	if a == 1:
		side1.add(b)
	
	elif b == n:
		side2.add(a)

print(("" if side1 & side2 else "IM") + "POSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
info = [list(map(int, input().split())) for _ in range(m)]
info = sorted(info, key=lambda x: x[0])

queue = []
for regular in info:
	if regular[0] == 1:
		queue.append(regular[1])

	elif (regular[0] in queue) and regular[1] == n:
		print("POSSIBLE")
		break
else:
	print("IMPOSSIBLE")

Fixed submission:
n, m = map(int, input().split())
side1 = set()
side2 = set()

for i in range(m):
	a, b = map(int, input().split())

	if a == 1:
		side1.add(b)
	
	elif b == n:
		side2.add(a)

print(("" if side1 & side2 else "IM") + "POSSIBLE")