#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const long long linf = (long long)1e18;
const int mod = (int)1e9 + 7;
const long double eps = (long double)1e-8;
const int maxn = (int)3e5 + 5;
const long double pi = acos(-1);
int n, m;
vector<int> a[maxn], vc[maxn], v0;
int t0[maxn], t1[maxn], t[maxn];
int ans;
int cnt;
vector<int> vans;
void dfs(int v, int z) {
  if (t[v] || v == 0) return;
  t[v] = z;
  vc[z].push_back(v);
  for (auto to : a[v]) {
    dfs(to, z);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (auto i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  memset((t0), 0, sizeof(t0));
  v0.clear();
  t0[0] = 1;
  for (auto to : a[0]) {
    t0[to] = 1;
    v0.push_back(to);
  }
  ans = inf;
  memset((t), 0, sizeof(t));
  cnt = 0;
  for (auto v : v0) {
    for (auto to : a[v]) {
      if (to != 0 && !t0[to]) {
        ans = 5;
        vans.clear();
        vans.push_back(0);
        vans.push_back(v);
        vans.push_back(to);
        vans.push_back(0);
        vans.push_back(n - 1);
      }
    }
    if (t[v]) continue;
    ++cnt;
    vc[cnt].clear();
    dfs(v, cnt);
  }
  for (auto i = 1; i <= cnt; ++i) {
    if (ans < inf) break;
    int u = -1;
    for (auto v : vc[i]) {
      if (((int)(a[v]).size()) != ((int)(vc[i]).size())) u = v;
    }
    if (u == -1) continue;
    memset((t1), 0, sizeof(t1));
    t1[u] = 1;
    for (auto to : a[u]) {
      t1[to] = 1;
    }
    for (auto to : a[u]) {
      if (to == 0 || ans < inf) continue;
      for (auto to1 : a[to]) {
        if (to1 != 0 && to1 != u && !t1[to1]) {
          ans = 6;
          vans.clear();
          vans.push_back(0);
          vans.push_back(u);
          vans.push_back(to);
          vans.push_back(to1);
          vans.push_back(u);
          vans.push_back(n - 1);
          break;
        }
      }
    }
    assert(ans < inf);
  }
  memset(t, -1, sizeof t);
  vector<int> q;
  q.push_back(0);
  int l = 0;
  t[0] = 0;
  while (l < ((int)(q).size())) {
    int v = q[l++];
    for (auto to : a[v]) {
      if (t[to] != -1) continue;
      t[to] = v;
      q.push_back(to);
    }
  }
  if (t[n - 1] != -1) {
    int v = n - 1;
    vector<int> vc;
    while (v != 0) {
      vc.push_back(v);
      v = t[v];
    }
    vc.push_back(0);
    reverse((vc).begin(), (vc).end());
    if (((int)(vc).size()) < ((int)(vans).size()) ||
        ((int)(vans).size()) == 0) {
      vans = vc;
      ans = ((int)(vans).size());
    }
  }
  if (ans < inf)
    cout << ans - 1 << endl;
  else
    cout << -1 << endl;
  if (ans < inf) {
    for (auto x : vans) {
      cout << x + 1 << " ";
    }
    cout << endl;
  }
  return 0;
}
