#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10, inf = 1e9;
vector<int> g[N];
int vis[N], bfs_clock, n, q[N], fro, rea, m, p[N], las[N], d[N];
bool vis2[N];
void bfs(int st) {
  fro = rea = 0;
  ++bfs_clock;
  vis[st] = bfs_clock;
  d[st] = 0;
  las[st] = 0;
  q[rea++] = st;
  while (fro < rea)
    for (int i = 0, u = q[fro++], v; i < g[u].size(); ++i)
      if (vis[v = g[u][i]] != bfs_clock) {
        d[v] = d[u] + 1;
        las[v] = u;
        vis[v] = bfs_clock;
        q[rea++] = v;
      }
}
void Solve_path() {
  for (int x = n; x; x = las[x]) p[d[x]] = x;
  printf("%d\n", min(d[n], 4));
  if (d[n] <= 4) {
    for (int i = 0; i <= d[n]; ++i) printf("%d ", p[i]);
    puts("");
  } else
    printf("%d %d %d %d %d\n", p[0], p[1], p[2], p[0], p[d[n]]);
}
void Solve4() {
  int en = 1;
  for (int i = 1; i <= n; ++i)
    if (vis[i] == bfs_clock && d[i] == 2) {
      en = i;
      break;
    }
  for (int x = en; x; x = las[x]) p[d[x]] = x;
  printf("4\n%d %d %d %d %d\n", p[0], p[1], p[2], p[0], n);
}
void Solve5() {
  for (int i = 2; i <= n; ++i)
    if (vis[i] == bfs_clock) {
      for (int j = 0; j < g[i].size(); ++j)
        if (g[i][j] == 1) {
          g[i].erase(g[i].begin() + j);
          break;
        }
    }
  bool exist = false;
  for (int i = 0, v; i < g[1].size() && !exist; ++i) {
    if (vis2[v = g[1][i]]) continue;
    bfs(v);
    for (int j = 0; j < rea; ++j) {
      vis2[q[j]] = true;
      if (g[q[j]].size() + 1 < rea) {
        v = q[j];
        break;
      }
    }
    if (g[v].size() + 1 < rea) {
      bfs(v);
      for (int j = 0, y; j < rea; ++j)
        if (d[y = q[j]] == 2) {
          for (int x = y; x; x = las[x]) p[d[x]] = x;
          printf("5\n1 %d %d %d %d %d\n", p[0], p[1], p[2], p[0], n);
          break;
        }
      exist = true;
    }
  }
  if (!exist) puts("-1");
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0, u, v; i < m; ++i) {
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  bfs(1);
  if (vis[n] == bfs_clock)
    Solve_path();
  else if (g[1].size() + 1 < rea)
    Solve4();
  else
    Solve5();
  return 0;
}
