#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
  return s * w;
}
const int p = 998244353;
int qp(int x, int y) {
  int res = 1;
  for (int t = x; y; y >>= 1, t = t * t % p)
    if (y & 1) res = res * t % p;
  return res;
}
unordered_set<int> e[1000003];
int d[1000003], fa[1000003];
int f[1000003][20];
void bfs() {
  memset(d, 0x3f, sizeof(d));
  queue<int> q;
  d[1] = 0;
  q.push(1);
  for (int i = 0; i < 20; ++i) f[1][i] = 1;
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i : e[x])
      if (d[i] > d[x] + 1) {
        d[i] = d[x] + 1;
        fa[i] = x;
        f[i][0] = x;
        for (int j = 1; j < 20; ++j) f[i][j] = f[f[i][j - 1]][j - 1];
        q.push(i);
      }
  }
  return;
}
int U[1000003], V[1000003];
signed main() {
  int n = read(), m = read();
  for (int i = 1, u, v; i <= m; ++i)
    u = read(), v = read(), U[i] = u, V[i] = v, e[u].insert(v), e[v].insert(u);
  bfs();
  if (e[1].empty()) {
    puts("-1");
    return 0;
  }
  if (e[1].find(n) != e[1].end()) {
    puts("1");
    printf("1 %d\n", n);
    return 0;
  }
  for (int i : e[1])
    if (e[i].find(n) != e[i].end()) {
      puts("2");
      printf("1 %d %d\n", i, n);
      return 0;
    }
  for (int i : e[1])
    for (int j : e[i])
      if (j != 1)
        if (e[j].find(n) != e[j].end()) {
          puts("3");
          printf("1 %d %d %d\n", i, j, n);
          return 0;
        }
  for (int i : e[1])
    for (int j : e[i])
      if (j != 1)
        if (e[j].find(1) == e[j].end()) {
          puts("4");
          printf("1 %d %d 1 %d\n", i, j, n);
          return 0;
        }
  if (d[n] == 4) {
    int A = n;
    stack<int> e;
    while (A != 1) {
      e.push(A);
      A = fa[A];
    }
    assert((int)e.size() == d[n]);
    printf("%d\n1 ", d[n]);
    while (!e.empty()) {
      printf("%d ", e.top());
      e.pop();
    }
    return 0;
  }
  int SSS = 0;
  for (int i = 1; i <= n; ++i) SSS += (d[i] == 1);
  for (int i = 1; i <= n; ++i)
    if (d[i] == 1) {
      unordered_map<int, int> vis;
      vis[i] = 1;
      int sss = 1;
      for (int j : e[i])
        if (d[j] == 1) ++sss, vis[j] = 1;
      if (sss < SSS) {
        for (int j : e[i])
          if (d[j])
            for (int k : e[j])
              if (!vis[k] && d[k]) {
                puts("5");
                printf("1 %d %d %d %d %d\n", i, j, k, i, n);
                return 0;
              }
      }
    }
  if (d[n] <= 1e9) {
    int A = n;
    stack<int> e;
    while (A != 1) {
      e.push(A);
      A = fa[A];
    }
    assert((int)e.size() == d[n]);
    printf("%d\n1 ", d[n]);
    while (!e.empty()) {
      printf("%d ", e.top());
      e.pop();
    }
    return 0;
  }
  puts("-1");
  return 0;
}
