#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
template <class T>
T gcd(T a, T b) {
  return a ? gcd(b % a, a) : b;
}
template <class T>
T sqr(T a) {
  return a * a;
}
template <class T>
T sgn(T a) {
  return a > 0 ? 1 : (a < 0 ? -1 : 0);
}
const double pi = acos(-1.0);
int n;
int m;
const int N = 3e5 + 10;
const int inf = 1e9;
vector<int> v[N];
int bfs(int s, int t, vector<int>& cert) {
  vector<int> from(n, -1), d(n, inf);
  vector<int> q;
  q.push_back(s);
  from[s] = s;
  d[s] = 0;
  int l = 0;
  while (l < ((int)(q).size())) {
    int x = q[l];
    l++;
    if (x == t) {
      break;
    }
    for (auto y : v[x]) {
      if (from[y] == -1) {
        from[y] = x;
        d[y] = d[x] + 1;
        q.push_back(y);
      }
    }
  }
  if (from[t] != -1) {
    int cur = t;
    while (s != cur) {
      cert.push_back(cur);
      cur = from[cur];
    }
    cert.push_back(s);
    reverse((cert).begin(), (cert).end());
  }
  return d[t];
}
bool check(int idx, int& idy, int& idz, vector<int>& was) {
  set<int> c((v[idx]).begin(), (v[idx]).end());
  for (auto y : v[idx]) {
    for (auto z : v[y]) {
      was[z] = 1;
      if (c.count(z) == 0 && z != idx) {
        idy = y;
        idz = z;
        return true;
      }
    }
  }
  return false;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    if (y != 0) v[x].push_back(y);
    if (x != 0) v[y].push_back(x);
  }
  vector<int> cert;
  int d = bfs(0, n - 1, cert);
  vector<int> was(n);
  if (d > 4) {
    set<int> c((v[0]).begin(), (v[0]).end());
    int idx = -1, idy = -1;
    if (check(0, idx, idy, was)) {
      d = 4;
      cert = {0, idx, idy, 0, n - 1};
    }
  }
  if (d > 5) {
    int idx = -1, idy = -1, idz = -1;
    fill((was).begin(), (was).end(), 0);
    for (int i = 0; i < ((int)(v[0]).size()); i++) {
      int x = v[0][i];
      if (((int)(v[x]).size()) < ((int)(v[0]).size()) - 1 && !was[x]) {
        idx = x;
        was[x] = true;
        if (check(idx, idy, idz, was)) {
          d = 5;
          cert = {0, idx, idy, idz, idx, n - 1};
          break;
        }
      }
    }
  }
  if (d + 1 == ((int)(cert).size())) {
    cout << d << endl;
    for (auto x : cert) {
      cout << x + 1 << " ";
    }
    cout << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}
