#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
int n, m;
int fa[N], siz[N], du[N], dis[N], pre[N], wrq[7];
vector<int> g[N], f[N];
int Seek(int x) { return fa[x] == x ? x : fa[x] = Seek(fa[x]); }
void Bfs(int s, vector<int> g[]) {
  static queue<int> Q;
  memset(dis, -1, sizeof dis);
  Q.push(s);
  dis[s] = 0;
  for (; !Q.empty();) {
    int x = Q.front();
    Q.pop();
    for (int v : g[x]) {
      if (dis[v] == -1) {
        dis[v] = dis[x] + 1;
        pre[v] = x;
        Q.push(v);
      }
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1, x, y; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  Bfs(1, g);
  if (dis[n] != -1 && dis[n] <= 4) {
    printf("%d\n", dis[n]);
    for (int i = n; i; i = pre[i]) wrq[++*wrq] = i;
    for (int i = *wrq; i >= 1; --i) {
      printf("%d%c", wrq[i], " \n"[i == 1]);
    }
    return 0;
  }
  for (int i = 1; i <= n; ++i) {
    fa[i] = i;
    if (dis[i] == 2) {
      printf("4\n%d %d %d %d %d\n", 1, pre[i], i, 1, n);
      return 0;
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (dis[i] != 1) continue;
    for (int j : g[i]) {
      if (i > j && dis[j] == 1) {
        ++du[i], ++du[j];
        fa[Seek(i)] = Seek(j);
        f[i].push_back(j);
        f[j].push_back(i);
      }
    }
  }
  for (int i = 1; i <= n; ++i) ++siz[Seek(i)];
  for (int i = 1; i <= n; ++i) {
    if (siz[Seek(i)] - 1 == du[i]) continue;
    Bfs(i, f);
    for (int j = 1; j <= n; ++j) {
      if (dis[j] == 2) {
        printf("5\n%d %d %d %d %d %d\n", 1, i, pre[j], j, i, n);
        return 0;
      }
    }
  }
  puts("-1");
  return 0;
}
