#include <bits/stdc++.h>
using namespace std;
vector<int> G[300002];
int D[300002], p[300002], sz[300002], f = -1;
vector<int> cache;
void bfs(int x) {
  for (int i = 0; i < 300002; i++) D[i] = 2e9, p[i] = -1;
  queue<int> Q;
  Q.push(x);
  D[x] = 0;
  while (!Q.empty()) {
    x = Q.front();
    Q.pop();
    if (D[x] == 4) return;
    if (D[x] == 2) f = x;
    for (int u : G[x])
      if (D[u] > D[x] + 1) D[u] = D[x] + 1, Q.push(u), p[u] = x;
  }
}
void bfs2(int x) {
  cache.clear();
  queue<int> Q;
  Q.push(x);
  D[x] = 0;
  while (!Q.empty()) {
    x = Q.front();
    Q.pop();
    cache.push_back(x);
    for (int u : G[x])
      if (u != 0 && D[u] > D[x] + 1) D[u] = D[x] + 1, Q.push(u), p[u] = x;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  while (m--) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  if (G[0].empty()) {
    cout << -1 << endl;
    return 0;
  }
  bfs(0);
  if (D[n - 1] != 2e9) {
    cout << D[--n] << endl;
    vector<int> r;
    while (n != -1) {
      r.push_back(n + 1);
      n = p[n];
    }
    reverse(r.begin(), r.end());
    for (int u : r) cout << u << ' ';
    cout << endl;
  } else {
    if (f != -1) {
      int x = p[f];
      x++;
      f++;
      cout << 4 << endl;
      cout << 1 << ' ' << x << ' ' << f << ' ' << 1 << ' ' << n << endl;
    } else {
      for (int i = 0; i < 300002; i++) D[i] = 2e9, p[i] = -1;
      memset(sz, -1, sizeof sz);
      for (int uu : G[0])
        if (sz[uu] == -1) {
          bfs2(uu);
          for (int x : cache) sz[x] = cache.size();
          for (int u : cache) {
            if (sz[u] > G[u].size()) {
              set<int> s, t;
              for (int x : cache)
                if (x != u) s.insert(x);
              for (int v : G[u])
                if (v != 0) s.erase(v), t.insert(v);
              int z, w = -1;
              while (!s.empty()) {
                z = *s.begin();
                bool q = 0;
                for (int v : G[z])
                  if (t.count(v)) w = v;
                if (w != -1) break;
                s.erase(z);
              }
              cout << 5 << endl;
              cout << 1 << ' ' << u + 1 << ' ' << w + 1 << ' ' << z + 1 << ' '
                   << u + 1 << ' ' << n << endl;
              return 0;
            }
          }
        }
      cout << -1 << endl;
    }
  }
}
