#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:102400000,102400000")
const int maxn = 5e5 + 5;
int n, m;
vector<int> G[maxn];
bool vis[maxn];
int pre[maxn];
bool bfs(int u) {
  queue<pair<int, int> > que;
  que.push(make_pair(1, 0));
  memset(pre, -1, sizeof(pre));
  vis[1] = 1;
  while (!que.empty()) {
    pair<int, int> p = que.front();
    que.pop();
    int u = p.first, step = p.second;
    for (int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      if (vis[v]) continue;
      vis[v] = true;
      pre[v] = u;
      if (step + 1 <= 4) {
        que.push(make_pair(v, step + 1));
      }
    }
  }
  while (!que.empty()) que.pop();
  if (pre[n] == -1) return false;
  int pos = n;
  vector<int> ans;
  ans.push_back(pos);
  while (pre[pos] != -1) {
    ans.push_back(pre[pos]);
    pos = pre[pos];
  }
  reverse(ans.begin(), ans.end());
  if (ans.size() > 5) return false;
  printf("%d\n", ans.size() - 1);
  for (int i = 0; i < ans.size(); i++) printf("%d ", ans[i]);
  cout << endl;
  return true;
}
void display(int a, int b, int c, int d, int e, int f) {
  printf("5\n%d %d %d %d %d %d\n", a, b, c, d, e, f);
}
void bfs2(int x, vector<int> &cache) {
  vis[x] = 1;
  queue<int> que;
  que.push(x);
  cache.push_back(x);
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    for (int i = 0; i < G[u].size(); i++) {
      if (vis[G[u][i]] || u == 1) continue;
      vis[G[u][i]] = 1;
      que.push(G[u][i]);
      cache.push_back(G[u][i]);
    }
  }
}
set<int> mys[maxn];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].push_back(v), G[v].push_back(u);
    mys[u].insert(v);
    mys[v].insert(u);
  }
  if (m == 0) return puts("-1"), 0;
  if (n == 1) return printf("1\n1\n"), 0;
  if (bfs(1)) return 0;
  memset(vis, 0, sizeof(vis));
  for (int i = 0; i < G[1].size(); i++) {
    vis[G[1][i]] = 1;
  }
  for (int i = 0; i < G[1].size(); i++) {
    int u = G[1][i];
    for (int j = 0; j < G[u].size(); j++) {
      int v = G[u][j];
      if (v == 1 || vis[v]) continue;
      printf("4\n1 %d %d 1 %d\n", u, v, n);
      return 0;
    }
  }
  memset(vis, 0, sizeof(vis));
  vector<int> cache;
  for (int i = 0; i < G[1].size(); i++) {
    int u = G[1][i];
    if (vis[u]) continue;
    cache.clear();
    bfs2(u, cache);
    if (G[u].size() < cache.size()) {
      for (int j = 0; j < cache.size(); j++) {
        u = cache[j];
        if (!mys[u].count(1)) continue;
        if (G[u].size() >= cache.size()) continue;
        for (int k = 0; k < G[1].size(); k++) {
          int z = G[1][k];
          if (!vis[z] || mys[z].count(u) || z == u) continue;
          for (int f = 0; f < G[z].size(); f++) {
            int v = G[z][f];
            if (!mys[v].count(1) || !mys[v].count(u)) continue;
            if (v == 1) continue;
            display(1, u, v, z, u, n);
            return 0;
          }
        }
      }
    }
  }
  puts("-1");
  return 0;
}
