#include <bits/stdc++.h>
std::vector<int> node[524288];
int p[524288], c[524288];
int que[524288], cq, nq;
int a[5], ans;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    node[u].push_back(v);
    node[v].push_back(u);
  }
  for (int i = 1; i <= n; ++i) std::sort(node[i].begin(), node[i].end());
  que[nq++] = 1, p[1] = 1, c[1] = 0;
  while (nq != cq) {
    int u = que[cq++];
    for (auto v : node[u]) {
      if (p[v]) continue;
      p[v] = u, c[v] = c[u] + 1;
      if (c[v] < 5) que[nq++] = v;
    }
  }
  if (p[n] == 1)
    return printf("1\n%d %d\n", 1, n), 0;
  else if (p[p[n]] == 1)
    return printf("2\n%d %d %d\n", 1, p[n], n), 0;
  else if (p[p[p[n]]] == 1)
    return printf("3\n%d %d %d %d\n", 1, p[p[n]], p[n], n), 0;
  for (int i = 2; i < n; ++i) {
    if (p[p[i]] == 1 && node[i][0] != 1)
      return printf("4\n%d %d %d %d %d\n", 1, p[i], i, 1, n), 0;
  }
  for (int i = 2; i < n; ++i) {
    if (!p[i]) continue;
    const int u = i;
    for (auto it = node[u].begin() + 1; it != node[u].end(); ++it) {
      const int v = *it;
      p[v] = 0;
      for (auto itu = node[u].begin() + 1, itv = node[v].begin() + 1;
           itu != node[u].end() || itv != node[v].end(); ++itu, ++itv) {
        if (*itu == v) ++itu;
        if (*itv == u) ++itv;
        if (itu == node[u].end() && itv == node[v].end()) break;
        if (itu != node[u].end() && (itv == node[v].end() || *itu < *itv))
          return printf("5\n%d %d %d %d %d %d\n", 1, v, u, *itu, v, n), 0;
        if (itv != node[v].end() && (itu == node[u].end() || *itv < *itu))
          return printf("5\n%d %d %d %d %d %d\n", 1, u, v, *itv, u, n), 0;
      }
    }
  }
  printf("-1\n");
  return 0;
}
