#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 7;
int d[maxn], n, m, ans[17], tr[maxn];
bool inv[maxn];
vector<int> adj[maxn], can;
void bfs(int s) {
  queue<int> q;
  q.push(s);
  memset(d, 0, sizeof d);
  d[s] = 1, d[1] = 1;
  while (q.size()) {
    int u = q.front();
    q.pop();
    for (auto v : adj[u])
      if (!d[v]) tr[v] = u, d[v] = d[u] + 1, q.push(v);
  }
}
void enter() {
  ios_base::sync_with_stdio(), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  while (m--) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v), adj[v].push_back(u);
  }
}
void case1() {
  m = 0;
  while (n) ans[++m] = n, n = tr[n];
  cout << m - 1 << "\n";
  for (int i = m; i >= 1; --i) cout << ans[i] << " ";
}
void solve() {
  bool ok = 0;
  bfs(1);
  if (d[n]) {
    if (d[n] <= 4) {
      case1();
      return;
    }
    ok = 1;
  }
  for (int i = 1; i <= n; ++i)
    if (d[i] == 3) {
      cout << 4 << "\n"
           << 1 << " " << tr[i] << " " << i << " " << 1 << " " << n << "\n";
      return;
    }
  for (auto v : adj[n]) inv[v] = 1;
  for (auto v : adj[1])
    if (!inv[v]) can.push_back(v);
  srand(time(0));
  while (can.size()) {
    int r = rand() % can.size();
    int v = can[r];
    can[r] = can.back();
    can.pop_back();
    bfs(v);
    for (int i = 2; i <= n; ++i)
      if (d[i] == 3) {
        cout << 5 << "\n"
             << 1 << " " << v << " " << tr[i] << " " << i << " " << v << " "
             << n << "\n";
        return;
      }
  }
  if (ok) case1();
  puts("-1");
}
int main() {
  enter();
  solve();
}
