#include <bits/stdc++.h>
using namespace std;
int n, m, w[300005], d[300005], blo[300005], size[300005], cur, pre[300005];
int k, la[300005], ff[300005 * 2], flag[300005], q[300005], tot, po[300005];
struct node {
  int a, b;
} e[300005 * 2];
void add(int a, int b) {
  e[++k] = (node){a, b};
  ff[k] = la[a];
  la[a] = k;
  e[++k] = (node){b, a};
  ff[k] = la[b];
  la[b] = k;
}
void bfs() {
  int l = 1, r = 2;
  q[1] = 1;
  while (l < r) {
    int x = q[l++];
    for (int a = la[x]; a; a = ff[a])
      if (!w[e[a].b] && e[a].b > 1)
        q[r] = e[a].b, pre[q[r]] = x, w[q[r]] = w[x] + 1, r++;
  }
}
void dfs(int x) {
  size[blo[x] = cur]++;
  flag[x] = 1;
  for (int a = la[x]; a; a = ff[a])
    if (e[a].b != 1) {
      d[x]++;
      if (!flag[e[a].b]) dfs(e[a].b);
    }
}
int bfs(int S) {
  int l = 1, r = 2;
  q[1] = S;
  while (l < r) {
    int x = q[l++];
    if (w[x] == 2) return x;
    for (int a = la[x]; a; a = ff[a])
      if (!w[e[a].b] && e[a].b != S && e[a].b != 1)
        q[r] = e[a].b, pre[q[r]] = x, w[q[r]] = w[x] + 1, r++;
  }
}
int main() {
  int a, b;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) scanf("%d%d", &a, &b), add(a, b);
  bfs();
  if (w[n] && w[n] <= 4) {
    for (int x = n; x; x = pre[x]) po[++tot] = x;
    printf("%d\n", tot - 1);
    while (tot) printf("%d ", po[tot--]);
    printf("\n");
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    if (w[i] == 2) {
      printf("4\n");
      printf("1 %d %d 1 %d\n", pre[i], i, n);
      return 0;
    }
  }
  memset(w, 0, sizeof(w));
  memset(pre, 0, sizeof(pre));
  for (int a = la[1]; a; a = ff[a])
    if (!flag[e[a].b]) ++cur, dfs(e[a].b);
  for (int a = la[1]; a; a = ff[a])
    if (d[e[a].b] < size[blo[e[a].b]] - 1) {
      int pos = bfs(e[a].b);
      for (int x = pos; x; x = pre[x]) po[++tot] = x;
      printf("5\n1 ");
      while (tot) printf("%d ", po[tot--]);
      printf("%d %d\n", e[a].b, n);
      return 0;
    }
  printf("-1\n");
  return 0;
}
