#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 100;
vector<int> G[N];
int n, m;
void Direct() {
  vector<int> dis(n + 1, 1e9), par(n + 1, -1);
  queue<int> que;
  que.push(1);
  dis[1] = 0;
  int mx = 0;
  while (que.size() > 0) {
    int u = que.front();
    que.pop();
    for (int v : G[u]) {
      if (dis[v] > dis[u] + 1) {
        dis[v] = dis[u] + 1;
        que.push(v);
        par[v] = u;
        mx = max(mx, dis[v]);
      }
    }
  }
  if (dis[n] <= 3) {
    vector<int> path;
    int v = n;
    while (v != -1) {
      path.push_back(v);
      v = par[v];
    }
    reverse(path.begin(), path.end());
    cout << path.size() - 1 << endl;
    for (int x : path) cout << x << " ";
    cout << endl;
    exit(0);
  }
  if (mx == 0) {
    cout << "-1" << endl;
    exit(0);
  }
  if (mx >= 2) {
    for (int i = 1; i <= n; i++) {
      if (dis[i] == 2) {
        vector<int> path;
        int v = i;
        while (v != -1) {
          path.push_back(v);
          v = par[v];
        }
        reverse(path.begin(), path.end());
        path.push_back(1);
        path.push_back(n);
        cout << path.size() - 1 << endl;
        for (int x : path) cout << x << " ";
        exit(0);
      }
    }
  }
  vector<int> dis2(n + 1, 1e9), par2(n + 1, -1);
  for (int i = 2; i <= n; i++) {
    if (dis[i] == 1e9) continue;
    if (dis2[i] != 1e9) continue;
    vector<int> nodes;
    queue<int> que;
    que.push(i);
    dis2[i] = 0;
    while (que.size() > 0) {
      int u = que.front();
      nodes.push_back(u);
      que.pop();
      for (int v : G[u]) {
        if (v == 1) continue;
        if (dis2[v] > dis2[u] + 1) {
          dis2[v] = dis2[u] + 1;
          que.push(v);
        }
      }
    }
    int rt = -1;
    int sz = nodes.size();
    for (int x : nodes) {
      if ((int)G[x].size() != sz) {
        rt = x;
        break;
      }
    }
    if (rt == -1) continue;
    for (int x = 1; x <= n; x++) {
      dis2[x] = 1e9;
    }
    que.push(rt);
    dis2[rt] = 0;
    int ttt = -1;
    while (que.size() > 0) {
      int u = que.front();
      nodes.push_back(u);
      que.pop();
      for (int v : G[u]) {
        if (v == 1) continue;
        if (dis2[v] > dis2[u] + 1) {
          dis2[v] = dis2[u] + 1;
          par2[v] = u;
          if (dis2[v] == 2) ttt = v;
          que.push(v);
        }
      }
    }
    vector<int> path;
    while (ttt != -1) {
      path.push_back(ttt);
      ttt = par2[ttt];
    }
    reverse(path.begin(), path.end());
    path.push_back(path[0]);
    path.insert(path.begin(), 1);
    path.push_back(n);
    cout << path.size() - 1 << endl;
    for (int x : path) {
      cout << x << " ";
    }
    cout << endl;
    exit(0);
  }
  cout << "-1" << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  Direct();
  return 0;
}
