#include<bits/stdc++.h>
using namespace std ;
#define F first
#define S second
const int N = 2e5+5 ;
const int M = 4e5+5 ;
int n , m , vis[M] ;
vector<pair<int,int>> nei[N] ;
vector<int> path ;
int GetMove(){
int ret ; cin >> ret ; return ret ;
}
void MakeMove(int v){
cout << v << endl ;
}
bool dfs(int node){
path.push_back(node) ;
bool flag = false ;
for(auto it:nei[node]){
if(vis[it.S]) continue ;
flag = true ;
vis[it.S] = 1 ;
if(dfs(it.F)) return true ;
vis[it.S] = 0 ;
}
if(node==1 && !flag) return true ;
path.pop_back() ;
return false ;
}
int main(){
cin >> n >> m ;
for(int i=0 ; i<m ; i++){
int u , v ; cin >> u >> v ;
nei[u].push_back({v,i}) ; nei[v].push_back({u,i}) ;
}
if(!dfs(1)){
cout << "NO" << endl ; return 0 ;
}
cout << "YES" << endl ;
while(true){
int temp = GetMove() ;
if(!temp) break ;
for(int i=1 ; i<path.size() ; i++){
if(path[i-1]==1 && path[i]==temp){
for(int j=i+1 ; j<path.size() ; j++){
MakeMove(path[j]) ;
if(path[j]==1) break ;
}
}
else if(path[i-1]==temp && path[i]==1){
for(int j=i-2 ; j>=0 ; j--){
MakeMove(path[j]) ;
if(path[j]==1) break ;
}
}
else continue ;
break ;
}
}
return 0 ;
}