#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int vis[N], dis[N], pre[N], q[N], sta[N], fa[N], siz[N], rd[N];
int to[N << 1], nx[N << 1], st[N];
int n, m, tot;
inline void add(int u, int v) {
  to[++tot] = v, nx[tot] = st[u], st[u] = tot;
  to[++tot] = u, nx[tot] = st[v], st[v] = tot;
}
inline int getfa(int x) { return fa[x] == x ? x : fa[x] = getfa(fa[x]); }
inline void bfs(int s) {
  memset(dis, 0x3f, sizeof(dis));
  memset(pre, 0, sizeof(pre));
  memset(vis, 0, sizeof(vis));
  int h = 1, t = 0;
  q[++t] = s, vis[s] = 1, dis[s] = 0;
  while (h <= t) {
    int x = q[h++];
    for (int i = st[x]; i; i = nx[i]) {
      if (!vis[to[i]] && to[i] != 1) {
        dis[to[i]] = dis[x] + 1, pre[to[i]] = x;
        vis[to[i]] = 1;
        q[++t] = to[i];
      }
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    add(u, v);
  }
  bfs(1);
  if (dis[n] <= 4) {
    printf("%d\n", dis[n]);
    int top = 0, p = n;
    while (pre[p]) sta[++top] = p, p = pre[p];
    sta[++top] = p;
    while (top) printf("%d ", sta[top--]);
    return 0;
  }
  for (int i = 2; i < n; ++i)
    if (dis[i] == 2) {
      printf("4\n%d %d %d %d %d", 1, pre[i], i, 1, n);
      return 0;
    }
  int top = 0;
  for (int i = 2; i < n; ++i)
    if (dis[i] == 1) sta[++top] = i, fa[i] = i, siz[i] = 1;
  for (int i = 1; i <= top; ++i)
    for (int j = st[sta[i]]; j; j = nx[j]) {
      if (to[j] == 1) continue;
      int x = getfa(to[j]), y = getfa(sta[i]);
      ++rd[sta[i]];
      if (x == y) continue;
      fa[x] = y, siz[y] += siz[x];
    }
  for (int i = 1; i <= top; ++i) {
    int x = sta[i];
    if (siz[getfa(x)] - 1 == rd[x]) continue;
    bfs(x);
    for (int j = 2; j < n; ++j)
      if (dis[j] == 2) {
        printf("5\n%d %d %d %d %d %d", 1, x, pre[j], j, x, n);
        return 0;
      }
  }
  puts("-1");
  return 0;
}
