#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000;
const int nmax = 300005;
vector<int> g[1 + nmax];
int dist1[1 + nmax], deg[1 + nmax], reconst1[1 + nmax], dist2[1 + nmax],
    reconst2[1 + nmax];
vector<int> minpath, aux;
void bfs(int *d, int *reconst, int start, int dini = 0, int dadd = 1,
         int skipnode = 0) {
  queue<int> q;
  d[start] = dini;
  q.push(start);
  while (q.size()) {
    int from = q.front();
    q.pop();
    for (int u : g[from])
      if (d[u] == INF && u != skipnode) {
        d[u] = d[from] + dadd;
        q.push(u);
        reconst[u] = from;
      }
  }
}
bool visited[1 + nmax];
vector<int> component;
void dfs(int node) {
  visited[node] = 1;
  for (int it : g[node])
    if (!visited[it] && it != 1) dfs(it);
  component.push_back(node);
}
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
    if (x != 1 && y != 1) {
      deg[x]++;
      deg[y]++;
    }
  }
  bool flag = 0;
  for (int i = 1; i <= n; i++) dist1[i] = INF;
  bfs(dist1, reconst1, 1);
  for (int i = 1; i <= n; i++)
    if (dist1[i] != INF) flag |= (dist1[i] > 1);
  if (flag == 0) {
    for (int i = 2; i <= n; i++) {
      if (!visited[i] && dist1[i] != INF) {
        component.clear();
        dfs(i);
        bool aux = 1;
        for (int j : component)
          if (deg[j] != (component.size() - 1)) aux = 0;
        if (aux == 0) flag = 1;
      }
    }
  }
  int sol = dist1[n];
  if (sol != INF) {
    int x = n;
    while (x != 0) {
      minpath.push_back(x);
      x = reconst1[x];
    }
    sol = minpath.size();
  }
  if (flag == 0 && sol == INF)
    cout << -1;
  else {
    for (int it = 1; it <= n; it++) {
      if (dist1[it] == 2 && 5 < sol) {
        sol = 5;
        aux.clear();
        minpath.clear();
        int x = it;
        while (x != 0) {
          aux.push_back(x);
          x = reconst1[x];
        }
        minpath.push_back(n);
        minpath.push_back(aux.back());
        for (int j : aux) minpath.push_back(j);
      }
    }
    for (int it : g[1]) {
      for (int i = 1; i <= n; i++) {
        dist2[i] = INF;
        reconst2[i] = 0;
      }
      bfs(dist2, reconst2, it, 0, 1, 1);
      bool flg = 0;
      for (int i = 2; i <= n; i++) {
        if (dist2[i] == 2 && 6 < sol) {
          sol = 6;
          aux.clear();
          minpath.clear();
          int x = i;
          while (x != 0) {
            aux.push_back(x);
            x = reconst2[x];
          }
          minpath.push_back(n);
          minpath.push_back(aux.back());
          for (int j : aux) minpath.push_back(j);
          minpath.push_back(1);
          flg = 1;
          break;
        }
      }
      if (flg == 1) break;
    }
    reverse(minpath.begin(), minpath.end());
    cout << sol - 1 << "\n";
    for (int i : minpath) cout << i << " ";
  }
  return 0;
}
