Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
judge = 0 #0:不可,1:可

if(M >= 2):
 #N*N行列 島a~b間に定期便あり:1,なし:0
 island = []
 for i in range(N):
  island.append([0]*N)

 island1 = []
 for i in range(M):
  a,b = map(int,input().split())
  a,b = a-1,b-1
  island[a][b] = 1
  island[b][a] = 1
  if(a == 0):
    island1.append(b)
  elif(b == 0):
    island1.append(b)

 for i in island1:
  if(island[i][N-1] == 1):#配列(リスト)の要素のアクセスO(1)
    judge = 1
    break
    
if(judge == 0):
  print('IMPOSSIBLE')
else:
  print('POSSIBLE')

Fixed submission:
N,M = map(int,input().split())
judge = 0 #0:不可,1:可

if(M >= 2):
 #リスト 島1~a間に定期便あり:1,なし:0
 island1 = [0]*N
 #リスト 島b~N間に定期便あり:1,なし:0
 islandN = [0]*N

 for i in range(M):
  a,b = map(int,input().split())
  a,b = a-1,b-1
  if(a == 0): island1[b] = 1
  if(b == 0): island1[a] = 1 
  if(a == N-1): islandN[b] = 1
  if(b == N-1): islandN[a] = 1
    
 for i in range(len(island1)):
  if((island1[i] == 1)and(islandN[i] == 1)):
    judge = 1
    break
    
if(judge == 0):
  print('IMPOSSIBLE')
else:
  print('POSSIBLE')

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
judge = 0 #0:不可,1:可

#島1 -> 島N
island = []
island1 = [] #島1の定期便
for i in range(M):
  a,b = map(int,input().split())
  island.append([a,b])
  if(a == 1):
    island1.append(b)
  if(b == 1):
    island1.append(a)
    
for i in range(len(island)):#TLEの可能性しかない
 for j in range(len(island1)):
   if(island[i][0] == island1[j]):
     if(island[i][1] == N):
      judge = 1
      break
   if(island[i][1] == island1[j]):
     if(island[i][0] == N):
      judge = 1
      break
      
if(judge == 0):
  print('IMPOSSIBLE')
else:
  print('POSSIBLE')

Fixed submission:
N,M = map(int,input().split())
judge = 0 #0:不可,1:可

if(M >= 2):
 #リスト 島1~a間に定期便あり:1,なし:0
 island1 = [0]*N
 #リスト 島b~N間に定期便あり:1,なし:0
 islandN = [0]*N

 for i in range(M):
  a,b = map(int,input().split())
  a,b = a-1,b-1
  if(a == 0): island1[b] = 1
  if(b == 0): island1[a] = 1 
  if(a == N-1): islandN[b] = 1
  if(b == N-1): islandN[a] = 1
    
 for i in range(len(island1)):
  if((island1[i] == 1)and(islandN[i] == 1)):
    judge = 1
    break
    
if(judge == 0):
  print('IMPOSSIBLE')
else:
  print('POSSIBLE')

Buggy python submission (verdict: Time Limit Exceeded):
X=input().split()
N=int(X[0])
M=int(X[1])
A=[]
B=[]
C=[]
count=0
for i in range(M):
 Y=input().split()
 a=int(Y[0])
 b=int(Y[1])
 A.append(a) 
 B.append(b) 
for i in range(M):
 if(A[i]==1):
   C.append(B[i])
n=len(C)
for i in range(n):
 for j in range(M):
  if((C[i]==A[j])and(B[j]==N)): 
   count +=1
if(count==0):
 print("IMPOSSIBLE")
else:
 print("POSSIBLE")

Fixed submission:
N,M = map(int,input().split())
judge = 0 #0:不可,1:可

if(M >= 2):
 #リスト 島1~a間に定期便あり:1,なし:0
 island1 = [0]*N
 #リスト 島b~N間に定期便あり:1,なし:0
 islandN = [0]*N

 for i in range(M):
  a,b = map(int,input().split())
  a,b = a-1,b-1
  if(a == 0): island1[b] = 1
  if(b == 0): island1[a] = 1 
  if(a == N-1): islandN[b] = 1
  if(b == N-1): islandN[a] = 1
    
 for i in range(len(island1)):
  if((island1[i] == 1)and(islandN[i] == 1)):
    judge = 1
    break
    
if(judge == 0):
  print('IMPOSSIBLE')
else:
  print('POSSIBLE')

Buggy python submission (verdict: Time Limit Exceeded):
X=input().split()
N=int(X[0])
M=int(X[1])
A=[]
B=[]
C=[]
count=0

for i in range(M):
 Y=input().split()
 a=int(Y[0])
 b=int(Y[1])
 A.append(a) #A[i]=a[i]
 B.append(b) #B[i]=b[i]

for i in range(M):
 if(A[i]==1):
   C.append(B[i]) #島1から島Xへいく船についてXの値を格納
n=len(C)

for i in range(n):
 for j in range(M):
  if((C[i]==A[j])and(B[j]==N)): 
   count +=1
#島Xから出る船があるか
#その船の行き先が島Nか

if(count==0):
 print("IMPOSSIBLE")
else:
 print("POSSIBLE")


Fixed submission:
N,M = map(int,input().split())
judge = 0 #0:不可,1:可

if(M >= 2):
 #リスト 島1~a間に定期便あり:1,なし:0
 island1 = [0]*N
 #リスト 島b~N間に定期便あり:1,なし:0
 islandN = [0]*N

 for i in range(M):
  a,b = map(int,input().split())
  a,b = a-1,b-1
  if(a == 0): island1[b] = 1
  if(b == 0): island1[a] = 1 
  if(a == N-1): islandN[b] = 1
  if(b == N-1): islandN[a] = 1
    
 for i in range(len(island1)):
  if((island1[i] == 1)and(islandN[i] == 1)):
    judge = 1
    break
    
if(judge == 0):
  print('IMPOSSIBLE')
else:
  print('POSSIBLE')