#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 300000;
const int INF = 1 << 30;
vector<int> nbrs[MAX_N];
int ds[MAX_N], ps[MAX_N], qs[MAX_N + 1];
int vs[MAX_N];
bool used[MAX_N];
void printv(int n, int vs[]) {
  printf("%d\n", n - 1);
  for (int i = 0; i < n; i++)
    printf("%d%c", vs[i] + 1, (i + 1 < n) ? ' ' : '\n');
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    u--, v--;
    nbrs[u].push_back(v);
    nbrs[v].push_back(u);
  }
  fill(ds, ds + n, INF);
  memset(qs, -1, sizeof(qs));
  ds[0] = 0, ps[0] = -1;
  int gn = 1;
  queue<int> q;
  q.push(0);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    qs[ds[u]] = u;
    if (u == n - 1) break;
    vector<int> &nbru = nbrs[u];
    for (vector<int>::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
      int v = *vit;
      if (ds[v] >= INF) {
        ds[v] = ds[u] + 1, ps[v] = u;
        gn++;
        q.push(v);
      }
    }
  }
  int gl = n - 1;
  if (ds[gl] <= 4) {
    int k = 0;
    for (int u = gl; u >= 0; u = ps[u]) vs[k++] = u;
    reverse(vs, vs + k);
    printv(k, vs);
    return 0;
  }
  if (qs[2] >= 0) {
    vs[0] = 0, vs[1] = ps[qs[2]], vs[2] = qs[2];
    vs[3] = 0, vs[4] = gl;
    printv(5, vs);
    return 0;
  }
  for (vector<int>::iterator vit0 = nbrs[0].begin(); vit0 != nbrs[0].end();
       vit0++)
    if (!used[*vit0]) {
      used[*vit0] = true;
      int k = 0;
      vs[k++] = *vit0;
      queue<int> q;
      q.push(*vit0);
      while (!q.empty()) {
        int u = q.front();
        q.pop();
        vector<int> &nbru = nbrs[u];
        for (vector<int>::iterator vit = nbru.begin(); vit != nbru.end();
             vit++) {
          int v = *vit;
          if (v != 0 && !used[v]) {
            used[v] = true;
            vs[k++] = v;
            q.push(v);
          }
        }
      }
      if (k <= 2) continue;
      int st = -1;
      for (int i = 0; i < k; i++)
        if (nbrs[vs[i]].size() < k) st = vs[i];
      if (st < 0) continue;
      fill(ds, ds + n, INF);
      ds[st] = 0, ps[st] = -1;
      q.push(st);
      while (!q.empty()) {
        int u = q.front();
        q.pop();
        qs[ds[u]] = u;
        vector<int> &nbru = nbrs[u];
        for (vector<int>::iterator vit = nbru.begin(); vit != nbru.end();
             vit++) {
          int v = *vit;
          if (v != 0 && ds[v] >= INF) {
            ds[v] = ds[u] + 1, ps[v] = u;
            q.push(v);
          }
        }
      }
      vs[0] = 0;
      vs[1] = st, vs[2] = ps[qs[2]], vs[3] = qs[2];
      vs[4] = st, vs[5] = gl;
      printv(6, vs);
      return 0;
    }
  puts("-1");
  return 0;
}
