#include <bits/stdc++.h>
using namespace std;
const int maxn = 300006;
vector<int> g[maxn], c[maxn];
int vis[maxn], p[maxn];
int n, m;
int pa(int x) { return p[x] == x ? x : p[x] = pa(p[x]); }
vector<int> res;
void print(vector<int>& res, vector<int>& nres) {
  if (res.size() == 0 || (nres.size() > 1 && nres.size() < res.size())) {
    res = nres;
  }
  if (res.size() == 0) {
    cout << -1 << endl;
    exit(0);
  }
  cout << res.size() - 1 << endl;
  for (int x : res) cout << x << ' ';
  exit(0);
}
set<pair<int, int> > es;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
    es.insert(pair<int, int>(u, v));
    es.insert(pair<int, int>(v, u));
  }
  queue<int> q;
  q.push(1);
  vis[1] = 1;
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int t : g[x])
      if (!vis[t]) {
        vis[t] = x;
        q.push(t);
      }
  }
  if (vis[n]) {
    for (int x = n; x != 1; x = vis[x]) res.push_back(x);
    res.push_back(1);
    reverse(res.begin(), res.end());
  }
  vector<int> nres;
  memset(vis, 0, sizeof vis);
  vis[1] = 1;
  for (auto t : g[1]) vis[t] = 1;
  for (auto x : g[1])
    if (vis[x]) {
      for (auto t : g[x])
        if (!vis[t]) {
          nres = {1, x, t, 1, n};
          print(res, nres);
        }
    }
  for (int i = 0; i <= n; i++) {
    p[i] = i;
  }
  for (auto x : g[1])
    for (auto t : g[x])
      if (t != 1) {
        p[pa(x)] = pa(t);
      }
  for (auto x : g[1]) {
    c[pa(x)].push_back(x);
  }
  for (auto x : g[1]) {
    if (g[x].size() < c[pa(x)].size()) {
      set<int> s(g[x].begin(), g[x].end());
      s.erase(1);
      for (auto t : g[x])
        if (t != 1) {
          for (auto k : g[t])
            if (k != 1 && k != t && k != x && !s.count(k)) {
              nres = {1, x, t, k, x, n};
              print(res, nres);
            }
        }
    }
  }
  print(res, nres);
  return 0;
}
