#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 99;
vector<int> g[N], c;
set<int> e[N];
int n, m, pre[N];
bool vis[N];
bool bfs(int u) {
  queue<pair<int, int> > q;
  q.push({1, 0});
  memset(pre, -1, sizeof pre);
  vis[1] = 1;
  while (!q.empty()) {
    pair<int, int> p = q.front();
    q.pop();
    int u = p.first, dis = p.second;
    for (int i = 0; i < g[u].size(); i++)
      if (!vis[g[u][i]]) {
        vis[g[u][i]] = 1;
        pre[g[u][i]] = u;
        if (dis < 4) q.push({g[u][i], dis + 1});
      }
  }
  while (!q.empty()) q.pop();
  if (pre[n] == -1) return 0;
  int pos = n;
  vector<int> ans;
  ans.push_back(pos);
  while (pre[pos] != -1) {
    ans.push_back(pre[pos]);
    pos = pre[pos];
  }
  reverse(ans.begin(), ans.end());
  if (ans.size() > 5) return 0;
  printf("%d\n", ans.size() - 1);
  for (int i = 0; i < ans.size(); i++) printf("%d ", ans[i]);
}
void bfs2(int x) {
  vis[x] = 1;
  queue<int> q;
  q.push(x);
  c.push_back(x);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < g[u].size(); i++)
      if (!vis[g[u][i]] && u != 1) {
        vis[g[u][i]] = 1;
        q.push(g[u][i]);
        c.push_back(g[u][i]);
      }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  if (!m) {
    printf("-1");
    return 0;
  }
  int x, y;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
    e[x].insert(y);
    e[y].insert(x);
  }
  if (bfs(1)) return 0;
  memset(vis, 0, sizeof vis);
  for (int i = 0; i < g[1].size(); i++) vis[g[1][i]] = 1;
  for (int i = 0; i < g[1].size(); i++)
    for (int j = 0; j < g[g[1][i]].size(); j++) {
      int u = g[g[1][i]][j];
      if (u != 1 && !vis[u]) {
        printf("4\n1 %d %d 1 %d\n", g[1][i], u, n);
        return 0;
      }
    }
  memset(vis, 0, sizeof vis);
  for (int i = 0; i < g[1].size(); i++)
    if (!vis[g[1][i]]) {
      c.clear();
      int u = g[1][i];
      bfs2(u);
      if (g[u].size() < c.size())
        for (int j = 0; j < c.size(); j++)
          if (e[c[j]].count(1) && g[c[j]].size() < c.size()) {
            u = c[j];
            for (int k = 0; k < g[1].size(); k++)
              if (vis[g[1][k]] && !e[g[1][k]].count(u) && u != g[1][k] &&
                  g[g[1][k]].size() < c.size()) {
                int z = g[1][k];
                for (int l = 0; l < g[z].size(); l++)
                  if (e[g[z][l]].count(1) && e[g[z][l]].count(u) &&
                      g[z][l] != 1) {
                    printf("5\n1 %d %d %d %d %d", u, g[z][l], z, u, n);
                    return 0;
                  }
              }
          }
    }
  printf("-1");
}
