#include <bits/stdc++.h>
using namespace std;
int n, m, x, y, ans;
int ss[300005], s;
int r[300005], q[300005], num, qq[300005], p[300005];
int to[2 * 300005], ne[2 * 300005], la[2 * 300005], tot;
int d[300005], head, tail, las[300005], dis[300005];
bool pp;
void init() { freopen("f.in", "r", stdin); }
void link(int u, int v) { to[++tot] = v, ne[tot] = la[u], la[u] = tot; }
bool pd(int a, int b) {
  if (a == b) return true;
  for (int k = la[a]; k; k = ne[k])
    if (to[k] == b) return true;
  return false;
}
void run(int t) {
  for (int i = la[t]; i; i = ne[i]) {
    x = to[i];
    if (pp && x == 1) continue;
    for (int j = la[x]; j; j = ne[j]) {
      y = to[j];
      if (pp && y == 1) continue;
      if (!pd(t, y)) {
        ss[++s] = t;
        ss[++s] = x;
        ss[++s] = y;
        ss[++s] = t;
        ss[++s] = n;
        ans += 4;
        return;
      }
    }
  }
}
void run_2(int t) {
  if (q[t]) return;
  q[t] = 1, num++;
  for (int i = la[t]; i; i = ne[i]) {
    int x = to[i];
    run_2(x);
  }
}
void run_3(int t) {
  if (p[t]) return;
  p[t] = 1;
  if (r[t] == num) qq[t] = 1;
  for (int i = la[t]; i; i = ne[i]) {
    int x = to[i];
    run_3(x);
  }
}
void write(int t) {
  if (!t) return;
  write(las[t]);
  printf("%d ", d[t]);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    link(x, y);
    link(y, x);
    r[x]++;
    r[y]++;
  }
  head = 0, tail = 1;
  d[1] = 1, q[1] = 1;
  while (++head <= tail) {
    if (dis[head] > 3) break;
    int now = d[head];
    for (int i = la[now]; i; i = ne[i]) {
      x = to[i];
      if (q[x]) continue;
      q[x] = 1;
      if (x == n) {
        printf("%d\n", dis[head] + 1);
        write(head);
        printf("%d", n);
        return 0;
      }
      tail++;
      d[tail] = x;
      dis[tail] = dis[head] + 1;
      las[tail] = head;
    }
  }
  for (int i = 1; i <= tail; i++) {
    int now = d[i];
    if (dis[i] == 2 && !pd(1, now)) {
      printf("4\n");
      write(i);
      printf("1 %d", n);
      return 0;
    }
  }
  head--;
  while (++head <= tail) {
    if (dis[head] > 4) break;
    int now = d[head];
    for (int i = la[now]; i; i = ne[i]) {
      x = to[i];
      if (q[x]) continue;
      q[x] = 1;
      if (x == n) {
        printf("%d\n", dis[head] + 1);
        write(head);
        printf("%d", n);
        return 0;
      }
      tail++;
      d[tail] = x;
      dis[tail] = dis[head] + 1;
      las[tail] = head;
    }
  }
  ss[++s] = 1;
  pp = 1;
  memset(q, 0, sizeof(q));
  q[1] = 1;
  for (int i = la[1]; i; i = ne[i]) {
    x = to[i];
    if (q[x]) continue;
    num = 0;
    run_2(x);
    run_3(x);
  }
  q[1] = 1;
  for (int i = la[1]; i; i = ne[i]) {
    x = to[i];
    if (qq[x]) continue;
    run(x);
    if (ans) {
      printf("%d\n", ans + 1);
      for (int i = 1; i <= s; i++) printf("%d ", ss[i]);
      return 0;
    }
  }
  printf("-1");
  return 0;
}
