#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int n, m, d[N], pre[N];
vector<int> adj[N];
bool check[N];
void bfs(int v) {
  queue<int> pq;
  pq.push(v);
  memset(d, -1, sizeof d);
  d[v] = 0;
  d[1] = 0;
  while (!pq.empty()) {
    int now = pq.front();
    pq.pop();
    for (auto& x : adj[now]) {
      if (d[x] == -1) {
        d[x] = d[now] + 1;
        pre[x] = now;
        pq.push(x);
      }
    }
  }
}
void sol() {
  vector<int> res;
  int dist = d[n];
  int i = n;
  if (dist != -1) {
    while (i != 0) {
      res.push_back(i);
      i = pre[i];
    }
    reverse(res.begin(), res.end());
  }
  if (dist <= 4 && dist != -1) {
    cout << dist << '\n';
    for (auto& x : res) cout << x << ' ';
    return;
  }
  for (int i = 1; i <= n; i++) {
    if (d[i] == 2) {
      cout << 4 << '\n'
           << 1 << ' ' << pre[i] << ' ' << i << ' ' << 1 << ' ' << n;
      return;
    }
  }
  vector<int> ok;
  for (auto& x : adj[n]) check[x] = true;
  for (auto& x : adj[1])
    if (!check[x]) ok.push_back(x);
  while (!ok.empty()) {
    int r = rand() % ok.size();
    int v = ok[r];
    ok[r] = ok.back();
    ok.pop_back();
    bfs(v);
    for (int i = 1; i <= n; i++) {
      if (d[i] == 2) {
        cout << 5 << '\n'
             << 1 << ' ' << v << ' ' << pre[i] << ' ' << i << ' ' << v << ' '
             << n;
        return;
      }
    }
  }
  if (dist != -1) {
    cout << dist << '\n';
    for (auto& x : res) cout << x << ' ';
  } else
    cout << -1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  srand(time(NULL));
  cin >> n >> m;
  while (m--) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  bfs(1);
  sol();
}
