#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];
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 (to != 1 && 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 && x != 1 && to != 1) uni(x, to);
    if (!w[to]) dfs(to, x);
  }
  w[x] = 2;
}
void find_answer(long long a, long long b, long long c) {
  ty = 3;
  cout << 5 << endl
       << "1 " << b << " " << a << " " << c << " " << b << " " << n << endl;
  exit(0);
}
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;
  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);
  if (ans > 5) {
    for (long long i = 2; i < n; i++)
      if (r[fin(i)] > 1 && v[i].size() < r[fin(i)]) {
        bfs(i);
        for (long long j = 2; j < n; j++)
          if (d[j] == 2) find_answer(pr[j], i, j);
      }
  }
  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;
  }
}
