import sys input = sys.stdin.readline N,M=map(int,input().split()) EDGE=[list(map(int,input().split())) for i in range(M)] for i in range(M): EDGE[i][0]-=1 EDGE[i][1]-=1 if M%2==1: print(-1) exit() E=[[] for i in range(N)] for i in range(M): x,y=EDGE[i] E[x].append((y,i)) E[y].append((x,i)) ANS=["R"]*M NOW=0 Q=[0] USE=[0]*N USE[0]=1 while Q: x=Q.pop() for to,ind in E[x]: if to==N-1: continue if ANS[ind]=="R" and NOW