#include <bits/stdc++.h>
using namespace std;
void read(long long &x) { scanf("%lld", &x); }
void read(long long &x, long long &y) { scanf("%lld%lld", &x, &y); }
void read(long long &x, long long &y, long long &z) {
  scanf("%lld%lld%lld", &x, &y, &z);
}
void print(long long x) { printf("%lld ", x); }
void println(long long x) { printf("%lld\n", x); }
const long long N = 300000;
long long n, m, x, y, d[N + 10], ans = 1e9, res[N + 10], w[N + 10], pr[N + 10],
                                 u[N + 10], ty, last, p[N + 10], r[N + 10],
                                 cnt[N + 10];
vector<long long> v[N + 10];
unordered_map<int, int> G[N + 10];
long long fin(long long a) {
  if (a == p[a]) return a;
  return p[a] = fin(p[a]);
}
void uni(long long a, long long b) {
  a = fin(a), b = fin(b);
  if (a == b) {
    cnt[a]++;
    return;
  }
  if (r[a] > r[b])
    r[a] += r[b], cnt[a] += cnt[b] + 1, p[b] = a;
  else
    r[b] += r[a], cnt[b] += cnt[a] + 1, p[a] = b;
}
void bfs(long long x) {
  for (long long i = 1; i <= n; i++) d[i] = 1e9;
  queue<long long> q;
  d[x] = 0;
  q.push(x);
  while (!q.empty()) {
    x = q.front();
    q.pop();
    for (long long to : v[x])
      if (d[to] > d[x] + 1) d[to] = d[x] + 1, pr[to] = x, q.push(to);
  }
}
void dfs(long long x, long long prr) {
  w[x] = 1;
  for (long long to : v[x]) {
    if (to == prr) continue;
    if (w[to] != 2) uni(x, to);
    if (!w[to]) dfs(to, x);
  }
  w[x] = 2;
}
const int K = 300;
int tp[N + 10];
int used[N + 10];
void find_answer(long long a, long long b, long long c) {
  ty = 3;
  cout << 5 << '\n'
       << "1 " << b << " " << a << " " << c << " " << b << " " << n << '\n';
  exit(0);
}
inline void calc(int x, int p = 0) {
  used[x] = 1;
  for (int to : v[x]) {
    if (to == p) continue;
    if (used[to]) continue;
    if (x != 1 && to != 1 && p != 1 && p != 0) {
      if (!G[to].count(p)) {
        find_answer(x, to, p);
      }
    }
    calc(to, x);
  }
}
int main() {
  cin >> n >> m;
  for (long long i = 1; i <= m; i++)
    read(x, y), v[x].push_back(y), v[y].push_back(x);
  for (long long to : v[1]) u[to] = 1;
  for (int i = 1; i <= n; ++i) {
    G[i].reserve(v[i].size());
    for (int to : v[i]) G[i][to] = 1;
  }
  if (u[n]) {
    cout << 1 << endl << 1 << " " << n << endl;
    return 0;
  }
  bfs(1);
  if (d[n] < 1e9) ans = d[n], ty = 1;
  for (long long i = 2; i < n; i++)
    if (d[i] < 1e9 && !u[i] && d[i] + 2 < ans) ans = d[i] + 2, ty = 2, last = i;
  for (long long i = 1; i <= n; i++) p[i] = i, r[i] = 1, cnt[i] = 0;
  dfs(1, 0);
  x = fin(1);
  if (ans > 5) {
    int finded = 0;
    for (int i = 2; !finded && i <= n; ++i) {
      if (fin(1) == fin(i)) {
        if (v[i].size() <= K) {
          for (int a : v[i]) {
            for (int b : v[i])
              if (a != 1 && b != 1 && a != b && !G[a].count(b)) {
                find_answer(i, a, b);
                finded = 1;
                break;
              }
            if (finded) break;
          }
        } else {
          for (int j = 1; j <= n; ++j) tp[j] = 0;
          for (int to : v[i]) tp[to] = 1;
          for (int j = 2; j <= n && !finded; ++j)
            for (int to : v[j])
              if (to != 1 && tp[j] != tp[to] && j != i && to != i) {
                if (tp[j])
                  find_answer(j, i, to);
                else
                  find_answer(to, i, j);
                finded = 1;
                break;
              }
        }
      }
    }
  }
  if (ans == 1e9) {
    cout << -1;
    return 0;
  }
  if (ty == 1) {
    bfs(1);
    ans = 0;
    x = n;
    while (x) {
      res[++ans] = x;
      x = pr[x];
    }
    cout << ans - 1 << endl;
    for (long long i = ans; i >= 1; i--) printf("%lld ", res[i]);
    return 0;
  }
  if (ty == 2) {
    bfs(1);
    ans = 2;
    x = last;
    res[1] = n;
    res[2] = 1;
    while (x) {
      res[++ans] = x;
      x = pr[x];
    }
    cout << ans - 1 << endl;
    for (long long i = ans; i >= 1; i--) printf("%lld ", res[i]);
    return 0;
  }
}
