#include <bits/stdc++.h>
using namespace std;
inline int nxt_int() {
  int x = 0;
  int c = getchar(), n = 0;
  for (; !isdigit(c); c = getchar()) n = (c == '-');
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  return n ? -x : x;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l, int r) { return l + rng() % (r - l + 1); }
using unx = unsigned long long;
const int N = 300010;
int n, m;
unx pw[N], val[N];
set<int> ad[N];
int main() {
  n = nxt_int(), m = nxt_int();
  pw[0] = 1;
  for (int i = 1, _c = n; i <= _c; ++i) {
    pw[i] = pw[i - 1] * 19937;
    val[i] = pw[i] * i;
  }
  for (int i = 1, _c = m; i <= _c; ++i) {
    int u = nxt_int(), v = nxt_int();
    ad[u].insert(v);
    ad[v].insert(u);
    val[u] += pw[v] * v;
    val[v] += pw[u] * u;
  }
  vector<int> inq(n + 1), tr(n + 1);
  queue<int> q;
  q.push(1);
  inq[1] = 1;
  while (q.size()) {
    int u = q.front();
    q.pop();
    if (u == n) {
      if (inq[u] > 5) break;
      vector<int> path;
      while (u) {
        path.push_back(u);
        u = tr[u];
      }
      reverse(path.begin(), path.end());
      cout << inq[n] - 1 << "\n";
      for (auto& i : path) cout << i << " ";
      return 0;
    }
    for (auto& v : ad[u])
      if (!inq[v]) {
        tr[v] = u;
        inq[v] = inq[u] + 1;
        q.push(v);
      }
  }
  for (int j = 1, _c = n; j <= _c; ++j)
    if (inq[j] == 3) {
      int i = tr[j];
      cout << "4\n";
      cout << 1 << " " << i << " " << j << " " << 1 << " " << n << "\n";
      return 0;
    }
  for (auto& i : ad[1])
    for (auto& j : ad[i])
      if (j != 1 && val[i] != val[j]) {
        cout << "5\n";
        for (int t = 1, _c = n; t <= _c; ++t)
          if (t != i && t != j && t != 1) {
            if (ad[i].count(t) && !ad[j].count(t)) {
              cout << 1 << " " << j << " " << i << " " << t << " " << j << " "
                   << n << "\n";
              return 0;
            }
            if (ad[j].count(t) && !ad[i].count(t)) {
              cout << 1 << " " << i << " " << j << " " << t << " " << i << " "
                   << n << "\n";
              return 0;
            }
          }
      }
  cout << "-1\n";
}
