#include using namespace std; #define FOR(i,a,b) for (int i=(a);i<(b);i++) #define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--) #define REP(i,n) for (int i=0;i<(n);i++) #define RREP(i,n) for (int i=(n)-1;i>=0;i--) bool dp[6][20001]; int p1[6][20001]; vectorv[20001]; int main(){ int N,M; cin>>N>>M; REP(i,M){ int a,b; cin>>a>>b; v[a].push_back(b); v[b].push_back(a); } REP(i,6){ REP(j,20001){ dp[i][j]=false; } } REP(i,6){ REP(j,20001){ p1[i][j]=-1; } } dp[0][1]=true; REP(i,5){ REP(j,N+1){ if(dp[i][j]){ REP(k,v[j].size()){ int x=v[j][k]; if(x!=1){ if(p1[i+1][x]!=-1||p1[i][j]!=x){ if(p1[i+1][x]!=-1){ p1[i+1][x]=-2; }else{ p1[i+1][x]=j; } dp[i+1][x]=true; } } } } } } bool check=false; REP(i,N+1){ if(i==1)continue; if(dp[4][i]==true){ REP(j,v[i].size()){ if(v[i][j]==1)check=true; } } if(check)break; } /* REP(i,6){ REP(j,N+1){ cout<