// O(n^3 2^n) solution to monkey // Javier Gómez Serrano // Should it pass? #include #include #include using namespace std; int q[1 << 21], prev[1 << 21], shot[1 << 21]; int main(){ int n,m; while (cin >> n >> m, n+m){ memset(prev,-1,sizeof(prev)); vector > L(n); for (int i=0;i> x >> y; L[x].push_back(y); L[y].push_back(x); } int begin,end; begin = end = 0; q[end++]=(1< V; int path = 0; while (path != ((1<=0;i--) cout << " " << V[i]; cout << endl; } } return 0; }