Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split(" "))
l=[]
bone=[]
ans="IMPOSSIBLE"
for i in range(m):
		a,b=input().split(" ")
		if a=="1":l.append(b)
		if b==str(n):bone.append(a)

		
def cat_snuke():
	for i in l:
		for j in bone:
			if i == j:
				print("POSSIBLE")
				return 0
	print("IMPOSSIBLE")
	
cat_snuke()

Fixed submission:
n,m=map(int,input().split(" "))
l=[]
bone=[]
for i in range(m):
		a,b=input().split(" ")
		if a=="1":l.append(b)
		if b==str(n):bone.append(a)

ans=list(set(l) & set(bone))
if len(ans)!=0:
	print("POSSIBLE")
else:			
	print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split(" "))
l=[]
bone=[]
ans="IMPOSSIBLE"
f=False
for i in range(m):
	if f==False:
		a,b=input().split(" ")
		if a=="1":l.append(b)
		if b==str(n):bone.append(a)
		if len(l) != 0:
			for i in l:
				for j in bone:
					if i == j:
						ans="POSSIBLE"
						f=True
	else:a=input()
		
print(ans)


Fixed submission:
n,m=map(int,input().split(" "))
l=[]
bone=[]
for i in range(m):
		a,b=input().split(" ")
		if a=="1":l.append(b)
		if b==str(n):bone.append(a)

ans=list(set(l) & set(bone))
if len(ans)!=0:
	print("POSSIBLE")
else:			
	print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split(" "))
l=[]
bone=[]
ans="IMPOSSIBLE"
for i in range(m):
		a,b=input().split(" ")
		if a=="1":l.append(b)
		if b==str(n):bone.append(a)
for i in l:
	for j in bone:
		if i == j:
			ans="POSSIBLE"
print(ans)

Fixed submission:
n,m=map(int,input().split(" "))
l=[]
bone=[]
for i in range(m):
		a,b=input().split(" ")
		if a=="1":l.append(b)
		if b==str(n):bone.append(a)

ans=list(set(l) & set(bone))
if len(ans)!=0:
	print("POSSIBLE")
else:			
	print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split(" "))
l=[]
bone=[]
ans="IMPOSSIBLE"
f=False
for i in range(m):
		a,b=map(int,input().split(" "))
		if a==1:l.append(b)
		if b==n:bone.append(a)
for i in l:
	for j in bone:
		if i == j:
			ans="POSSIBLE"
print(ans)


Fixed submission:
n,m=map(int,input().split(" "))
l=[]
bone=[]
for i in range(m):
		a,b=input().split(" ")
		if a=="1":l.append(b)
		if b==str(n):bone.append(a)

ans=list(set(l) & set(bone))
if len(ans)!=0:
	print("POSSIBLE")
else:			
	print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split(" "))
l=[]
bone=[]
for i in range(m):
	a,b=map(int,input().split(" "))
	if a==1:l.append(b)
	if b==n:bone.append(a)

def cat_snuke():	
	for i in l:
		for j in bone:
			if i == j:
				print("POSSIBLE")
				return 0
		
	print("IMPOSSIBLE")

cat_snuke()


Fixed submission:
n,m=map(int,input().split(" "))
l=[]
bone=[]
for i in range(m):
		a,b=input().split(" ")
		if a=="1":l.append(b)
		if b==str(n):bone.append(a)

ans=list(set(l) & set(bone))
if len(ans)!=0:
	print("POSSIBLE")
else:			
	print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split(" "))
l=[]
bone=[]
ans=False
for i in range(m):
	a,b=map(int,input().split(" "))
	if a==1:l.append(b)
	if b==n:bone.append(a)
	
for i in l:
	for j in bone:
		if i == j:
			ans=True
	
if ans == True:print("POSSIBLE")
else:print("IMPOSSIBLE")


Fixed submission:
n,m=map(int,input().split(" "))
l=[]
bone=[]
for i in range(m):
		a,b=input().split(" ")
		if a=="1":l.append(b)
		if b==str(n):bone.append(a)

ans=list(set(l) & set(bone))
if len(ans)!=0:
	print("POSSIBLE")
else:			
	print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split(" "))
l=[]
bone=[]
ans=False
for i in range(m):
	a,b=map(int,input().split(" "))
	if a==1:l.append(b)
	if b==n:bone.append(a)

l.sort()
bone.sort()
for i in l:
	for j in bone:
		if i == j:
			ans=True
	
if ans == True:print("POSSIBLE")
else:print("IMPOSSIBLE")


Fixed submission:
n,m=map(int,input().split(" "))
l=[]
bone=[]
for i in range(m):
		a,b=input().split(" ")
		if a=="1":l.append(b)
		if b==str(n):bone.append(a)

ans=list(set(l) & set(bone))
if len(ans)!=0:
	print("POSSIBLE")
else:			
	print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split(" "))
l=[]
bone=[]
one_count=[]
count=0
for i in range(m):
	a,b=map(int,input().split(" "))
	l.append(a)
	l.append(b)
	if a==1:one_count.append(count)
	count=count+1
	if b==n:bone.append(a)
	count=count+1
	
def cat_snuke():
	for i in one_count:
		for j in bone:
			if l[i+1] == j:
				print("POSSIBLE")
				return 0
	print("IMPOSSIBLE")		
cat_snuke()

Fixed submission:
n,m=map(int,input().split(" "))
l=[]
bone=[]
for i in range(m):
		a,b=input().split(" ")
		if a=="1":l.append(b)
		if b==str(n):bone.append(a)

ans=list(set(l) & set(bone))
if len(ans)!=0:
	print("POSSIBLE")
else:			
	print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split(" "))
l=[]
bone=[]

for i in range(m):
	a,b=map(int,input().split(" "))
	l.append(a)
	l.append(b)
	if b==n:
		bone.append(a) #nと定期便がある島を記録	
def cat_snuke():
	count = 0
	for i in l:
		if i==1:
			for j in bone:
				if l[count+1] == j:
					print("POSSIBLE")
					return 0
		count=count+1
	print("IMPOSSIBLE")
		
cat_snuke()

Fixed submission:
n,m=map(int,input().split(" "))
l=[]
bone=[]
for i in range(m):
		a,b=input().split(" ")
		if a=="1":l.append(b)
		if b==str(n):bone.append(a)

ans=list(set(l) & set(bone))
if len(ans)!=0:
	print("POSSIBLE")
else:			
	print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split(" "))
l=[]
bone=[]
count = 0
ans="IMPOSSIBLE"
for i in range(m):
	a,b=map(int,input().split(" "))
	l.append(a)
	l.append(b)
	
	if b==n:
		bone.append(a) #nと定期便がある島を記録
for i in l:
	if i==1:
		for j in bone:
			if l[count+1] == j:
				ans="POSSIBLE"
				break
	count=count+1
		
print(ans)

Fixed submission:
n,m=map(int,input().split(" "))
l=[]
bone=[]
for i in range(m):
		a,b=input().split(" ")
		if a=="1":l.append(b)
		if b==str(n):bone.append(a)

ans=list(set(l) & set(bone))
if len(ans)!=0:
	print("POSSIBLE")
else:			
	print("IMPOSSIBLE")