#include <bits/stdc++.h>
using namespace std;
int N, sol = 300005, cont, m, ms, M, band, mark[300005], D[300005], P[300005],
       Pad[300005], mark2[300005], K;
int a, b, c, men, may;
queue<int> Q;
vector<int> G[300005];
void imprime(int nod) {
  if (nod) {
    imprime(Pad[nod]);
    cout << nod;
    if (nod != N) cout << " ";
  }
}
void imprime2(int nod) {
  cout << "4\n";
  cout << "1 " << Pad[nod] << " " << nod << " 1 " << N;
}
void imprime3(int nod) {
  mark2[1] = mark2[nod] = 1;
  for (auto ady : G[nod]) mark2[ady] = 1;
  for (auto ady : G[nod])
    if (ady != 1)
      for (auto sec : G[ady])
        if (!mark2[sec]) {
          cout << "5\n1 " << nod << " " << ady << " " << sec << " " << nod
               << " " << N;
          return;
        }
}
void bfs(int nod) {
  Q.push(nod);
  D[nod] = 1;
  while (!Q.empty()) {
    nod = Q.front();
    Q.pop();
    for (auto ady : G[nod]) {
      if (D[ady]) continue;
      D[ady] = D[nod] + 1;
      Pad[ady] = nod;
      Q.push(ady);
    }
  }
  if (D[N]) sol = D[N] - 1;
}
void check(int nod) {
  if (men > (int)G[nod].size()) men = G[nod].size(), m = nod;
  may = max(may, (int)G[nod].size());
}
void bfs2(int nod) {
  Q.push(nod);
  men = 300005, may = 0, c = 0;
  while (!Q.empty()) {
    nod = Q.front();
    check(nod);
    c++;
    if (!P[nod]) {
      sol = min(sol, 4);
      band = 1;
      imprime2(nod);
      return;
    }
    Q.pop();
    for (auto ady : G[nod]) {
      if (!mark[ady]) {
        Pad[ady] = nod;
        mark[ady] = 1;
        Q.push(ady);
      }
    }
  }
  if ((int)G[m].size() < c && !ms) ms = m;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> N >> M;
  for (int i = 1; i <= M; i++) {
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
    if (a > b) swap(a, b);
    if (a == 1) P[b] = 1;
  }
  bfs(1);
  if (sol != 300005 && sol <= 4) {
    cout << sol << "\n";
    imprime(N);
    return 0;
  }
  mark[1] = 1;
  for (auto ady : G[1]) {
    if (mark[ady]) continue;
    mark[ady] = 1;
    bfs2(ady);
    if (band) break;
    band = 0;
  }
  if (band) return 0;
  if (ms)
    imprime3(ms);
  else
    cout << "-1";
  return 0;
}
