#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
const int INF = 3 * N;
int d[N], pre[N];
vector<int> G[N];
int s, t;
bool used[N], vis[N];
void bfs(int u, vector<int>& vt) {
  queue<int> que;
  que.push(u);
  used[u] = true;
  vt.push_back(u);
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    for (auto v : G[u]) {
      if (!used[v]) {
        used[v] = true;
        que.push(v);
        vt.push_back(v);
      }
    }
  }
}
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);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  tie(s, t) = pair<int, int>(1, n);
  fill(d + 1, d + n + 1, INF);
  memset(pre, -1, sizeof pre);
  d[s] = 0;
  queue<int> que;
  que.push(s);
  int vx = -1;
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    for (auto v : G[u]) {
      if (d[v] == INF) {
        d[v] = 1 + d[u];
        que.push(v);
        pre[v] = u;
        if (d[v] == 2) {
          vx = v;
        }
      }
    }
  }
  if (d[t] <= 4) {
    printf("%d\n", d[t]);
    vector<int> Path;
    Path.push_back(t);
    while (Path.back() != s) {
      Path.push_back(pre[Path.back()]);
    }
    for (int i = Path.size() - 1; i >= 0; i--) {
      printf("%d%c", Path[i], " \n"[i == 0]);
    }
  } else if (vx != -1) {
    printf("4\n");
    printf("%d %d %d %d %d\n", s, pre[vx], vx, s, t);
  } else {
    if (d[t] == 5) {
      printf("%d\n", d[t]);
      vector<int> Path;
      Path.push_back(t);
      while (pre[Path.back()] != -1) {
        Path.push_back(pre[Path.back()]);
      }
      for (int i = Path.size(); i >= 0; i--) {
        printf("%d%c", Path[i], " \n"[i == 0]);
      }
      return 0;
    }
    used[s] = true;
    vis[s] = true;
    for (auto u : G[s]) {
      if (!used[u]) {
        vector<int> vt;
        bfs(u, vt);
        for (auto u : vt) {
          if (G[u].size() < vt.size()) {
            vector<int> vec;
            vec.push_back(u);
            vis[u] = true;
            for (auto v : G[u]) {
              if (v != s) {
                vec.push_back(v);
                vis[v] = true;
              }
            }
            for (auto v : vec) {
              for (auto w : G[v]) {
                if (vis[w] == false) {
                  printf("5\n");
                  printf("%d %d %d %d %d %d\n", s, u, v, w, u, t);
                  return 0;
                }
              }
            }
            for (auto v : vec) vis[v] = false;
            break;
          }
        }
      }
    }
    printf("-1\n");
  }
}
