#include #include #include #include int n, m; std::vector> g; std::vector d, p; int a, b, s = 10000000; bool dfs(int from, int to){ p[to] = from; d[to] = from == -1 ? 1 : d[from] + 1; bool retval = false; for (int i : g[to]) if (i != from){ if (d[i] == -1) retval = dfs(to, i) || retval; else if (d[to] + d[i] < s) a = to, b = i, s = d[to] + d[i], retval = true; } return retval; } int main(){ std::cin >> n >> m; g = std::vector>(n+1); for (int i = 0; i < m; ++i){ int u, v; std::cin >> u >> v; g[u].push_back(v); g[v].push_back(u); } d = std::vector(n+1, -1); p = std::vector(n+1, -1); if (!dfs(-1, 1)){ std::cout << "impossible" << std::endl; return 0; } std::cout << d[a] + d[b] << std::endl << '1'; std::vector solution; for (int i = a; i != 1; i = p[i]) solution.push_back(i); std::reverse(solution.begin(), solution.end()); for (int i = b; i != -1; i = p[i]) solution.push_back(i); for (int i : solution) std::cout << ' ' << i; std::cout << std::endl; return 0; }