#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long infl = 1LL << 60;
mt19937 rnd(time(0));
inline int myrand(int l, int r) { return rnd() % (r - l + 1) + l; }
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + c - '0', c = getchar();
  }
  return x * f;
}
const int maxn = 3e5 + 10;
vector<int> linker[maxn];
int n, m, q[maxn], dis[maxn], pre[maxn];
bool mark[maxn], vis[maxn];
vector<int> v;
void dfs(int x) {
  vis[x] = 1, v.push_back(x);
  for (int cur : linker[x])
    if (!vis[cur]) dfs(cur);
}
void print() {
  vector<int> ans(0);
  int x = n;
  while (x) ans.push_back(x), x = pre[x];
  reverse(ans.begin(), ans.end());
  for (int cur : ans) printf("%d ", cur);
  puts("");
}
int main() {
  n = read(), m = read();
  for (int i = 1; i <= m; i++) {
    int u = read(), v = read();
    linker[u].push_back(v);
    linker[v].push_back(u);
  }
  int head = 1, tail = 0;
  memset(dis, 0x3f, sizeof dis);
  q[++tail] = 1, dis[1] = 0;
  while (head <= tail) {
    int x = q[head++];
    for (int cur : linker[x])
      if (dis[cur] == inf) dis[cur] = dis[x] + 1, q[++tail] = cur, pre[cur] = x;
  }
  if (dis[n] <= 4) return printf("%d\n", dis[n]), print(), 0;
  for (int cur : linker[1]) mark[cur] = 1;
  mark[1] = 1;
  for (int cur : linker[1]) {
    for (int to : linker[cur])
      if (!mark[to]) {
        printf("%d\n%d %d %d %d %d\n", 4, 1, cur, to, 1, n);
        return 0;
      }
  }
  vis[1] = 1;
  for (int x : linker[1])
    if (!vis[x]) {
      dfs(x);
      for (int y : v) {
        if (mark[y] && linker[y].size() - 1 < v.size() - 1) {
          printf("%d\n", min(dis[n], 5));
          if (dis[n] < 5)
            print();
          else {
            memset(mark, 0, sizeof mark);
            for (int cur : linker[y]) mark[cur] = 1;
            mark[y] = 1;
            for (int cur : linker[y])
              if (cur != 1)
                for (int foo : linker[cur])
                  if (!mark[foo]) {
                    printf("%d %d %d %d %d %d\n", 1, y, cur, foo, y, n);
                    return 0;
                  }
          }
          return 0;
        }
      }
      v.clear();
    }
  if (dis[n] == inf)
    return puts("-1"), 0;
  else {
    printf("%d\n", dis[n]);
    print();
  }
  return 0;
}
