#!/usr/bin/env python3
p, q, s, g = (k := [0, 1] + [0] * ((i := [*map(int, input().split())])[0]))[:], [1], [], [[] for _ in range(i[0] + 1)]
for _ in range(i[1]): g[(x := list(map(int, input().split())))[0]].append(x[1]) or g[x[1]].append(x[0])
while q or print("impossible" if not s else f"{len(s)}\n{' '.join(str(r) for r in s)}"):
    for b in g[c := q.pop(0)]:
        if b != p[c] and p[b] and (not s or k[c] + k[b] < len(s)) and [pathb := [x := b], pathc := [y := c], 1][-1]:
            while p[x] != x: [pathb.append(x := p[x]) if x != p[x] else 0, pathc.append(y := p[y]) if y != p[y] else 0]
            s = pathc[::-1] + pathb
        if b != 1 and not p[b] and (q.append(b) or 1): p[b], k[b] = c, k[c] + 1
