#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define vi vector<int>
#define vvi vector<vi>
#define read(a) for(int i = 0; i < n; i++) cin >> a[i];
#define print(a) for(int i = 0; i < n; i++) cout << a[i] << " ";
#define pb push_back
#define pql priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define pqlv priority_queue<vi>
#define pqsv priority_queue<vi, vvi, greater<vi>>
#define endl '\n'
#define N 1234567
#define MOD 1000000007
vvi adj;
vi par, vis;
int n, mx;
bool dfs(int u, int d = 0) {
if(u == n) {
if(d > mx) {
mx = d;
return true;
}
return false;
}
if(vis[u])
return false;
vis[u] = 1;
bool ans = false;
for(int v : adj[u]) {
if(dfs(v, d + 1)) {
par[v] = u;
ans = true;
}
}
return ans;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
// cin >> t;
while(t--) {
int m;
cin >> n >> m;
adj.clear();
adj.resize(n + 1);
mx = 0;
par.assign(n + 1, -1);
vis.assign(n + 1, 0);
for(int i = 0; i < m; i++) {
int a, b;
cin >> a >> b;
adj[a].pb(b);
}
if(dfs(1, 0)) {
int v = n;
cout << mx + 1 << endl;
vi ret;
while(v != 1) {
ret.pb(v);
v = par[v];
}
ret.pb(1);
reverse(ret.begin(), ret.end());
for(int i : ret) cout << i << " ";
}
else {
cout << "IMPOSSIBLE";
}
cout << endl;
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiAKI2RlZmluZSBpbnQgbG9uZyBsb25nIGludAojZGVmaW5lIHZpIHZlY3RvcjxpbnQ+CiNkZWZpbmUgdnZpIHZlY3Rvcjx2aT4KI2RlZmluZSByZWFkKGEpICBmb3IoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSBjaW4gPj4gYVtpXTsKI2RlZmluZSBwcmludChhKSAgZm9yKGludCBpID0gMDsgaSA8IG47IGkrKykgY291dCA8PCBhW2ldIDw8ICIgIjsKI2RlZmluZSBwYiBwdXNoX2JhY2sKI2RlZmluZSBwcWwgcHJpb3JpdHlfcXVldWU8aW50PgojZGVmaW5lIHBxcyBwcmlvcml0eV9xdWV1ZTxpbnQsIHZpLCBncmVhdGVyPGludD4+CiNkZWZpbmUgcHFsdiBwcmlvcml0eV9xdWV1ZTx2aT4KI2RlZmluZSBwcXN2IHByaW9yaXR5X3F1ZXVlPHZpLCB2dmksIGdyZWF0ZXI8dmk+PgojZGVmaW5lIGVuZGwgJ1xuJwojZGVmaW5lIE4gMTIzNDU2NwojZGVmaW5lIE1PRCAxMDAwMDAwMDA3Cgp2dmkgYWRqOwp2aSBwYXIsIHZpczsKaW50IG4sIG14OwoKYm9vbCBkZnMoaW50IHUsIGludCBkID0gMCkgewogICAgaWYodSA9PSBuKSB7CiAgICAgICAgaWYoZCA+IG14KSB7CiAgICAgICAgICAgIG14ID0gZDsKICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgfQogICAgICAgIHJldHVybiBmYWxzZTsKICAgIH0KICAgIGlmKHZpc1t1XSkKICAgICAgICByZXR1cm4gZmFsc2U7CiAgICB2aXNbdV0gPSAxOwogICAgYm9vbCBhbnMgPSBmYWxzZTsKICAgIGZvcihpbnQgdiA6IGFkalt1XSkgewogICAgICAgIGlmKGRmcyh2LCBkICsgMSkpIHsKICAgICAgICAgICAgcGFyW3ZdID0gdTsKICAgICAgICAgICAgYW5zID0gdHJ1ZTsKICAgICAgICB9CiAgICB9CiAgICByZXR1cm4gYW5zOwp9CgpzaWduZWQgbWFpbigpIHsKICAgIGlvczo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsgCiAgICBjaW4udGllKDApOyAKICAgIGNvdXQudGllKDApOwogICAgaW50IHQgPSAxOwogICAgLy8gY2luID4+IHQ7CiAgICB3aGlsZSh0LS0pIHsKICAgICAgICBpbnQgbTsKICAgICAgICBjaW4gPj4gbiA+PiBtOwogICAgICAgIGFkai5jbGVhcigpOwogICAgICAgIGFkai5yZXNpemUobiArIDEpOwogICAgICAgIG14ID0gMDsKICAgICAgICBwYXIuYXNzaWduKG4gKyAxLCAtMSk7CiAgICAgICAgdmlzLmFzc2lnbihuICsgMSwgMCk7CiAgICAgICAgZm9yKGludCBpID0gMDsgaSA8IG07IGkrKykgewogICAgICAgICAgICBpbnQgYSwgYjsKICAgICAgICAgICAgY2luID4+IGEgPj4gYjsKICAgICAgICAgICAgYWRqW2FdLnBiKGIpOwogICAgICAgIH0KICAgICAgICBpZihkZnMoMSwgMCkpIHsKICAgICAgICAgICAgaW50IHYgPSBuOwogICAgICAgICAgICBjb3V0IDw8IG14ICsgMSA8PCBlbmRsOwogICAgICAgICAgICB2aSByZXQ7CiAgICAgICAgICAgIHdoaWxlKHYgIT0gMSkgewogICAgICAgICAgICAgICAgcmV0LnBiKHYpOwogICAgICAgICAgICAgICAgdiA9IHBhclt2XTsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXQucGIoMSk7CiAgICAgICAgICAgIHJldmVyc2UocmV0LmJlZ2luKCksIHJldC5lbmQoKSk7CiAgICAgICAgICAgIGZvcihpbnQgaSA6IHJldCkgICAgY291dCA8PCBpIDw8ICIgIjsKICAgICAgICB9CiAgICAgICAgZWxzZSB7CiAgICAgICAgICAgIGNvdXQgPDwgIklNUE9TU0lCTEUiOwogICAgICAgIH0KICAgICAgICBjb3V0IDw8IGVuZGw7CiAgICB9CglyZXR1cm4gMDsKfQ==