#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
const int N = 3e5 + 100;
const int INF = 1e9 + 7;
vector<int> g[N];
int d[N], p[N], deg[N], used[N];
set<int> adj[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; (i) < (m); ++i) {
    int v, u;
    cin >> v >> u;
    v--, u--;
    g[v].push_back(u);
    g[u].push_back(v);
    adj[u].insert(v);
    adj[v].insert(u);
    deg[v]++;
    deg[u]++;
  }
  for (int i = 0; (i) < (N); ++i) p[i] = -1, d[i] = INF;
  queue<int> q;
  q.push(0);
  d[0] = 0;
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (int to : g[v]) {
      if (d[to] > d[v] + 1) {
        d[to] = d[v] + 1;
        p[to] = v;
        q.push(to);
      }
    }
  }
  if (d[n - 1] <= 4) {
    cout << d[n - 1] << '\n';
    vector<int> path;
    path.push_back(n - 1);
    int now = n - 1;
    while (p[now] != -1) {
      now = p[now];
      path.push_back(now);
    }
    reverse((path).begin(), (path).end());
    for (int v : path) cout << v + 1 << " ";
    cout << '\n';
    return 0;
  }
  for (int v : g[0]) {
    for (int to : g[v]) {
      if (!to) continue;
      if (!adj[0].count(to)) {
        cout << 4 << '\n';
        cout << 1 << " " << v + 1 << " " << to + 1 << " " << 1 << " " << n
             << '\n';
        return 0;
      }
    }
  }
  for (int v : g[0]) {
    if (used[v]) continue;
    for (int to : g[v]) {
      if (!to) continue;
      assert(!used[to]);
      used[to] = 1;
      for (int to2 : g[to]) {
        if (to2 == v || to2 == 0) continue;
        if (!adj[v].count(to2)) {
          cout << 5 << '\n';
          cout << 1 << " " << v + 1 << " " << to + 1 << " " << to2 + 1 << " "
               << v + 1 << " " << n << '\n';
          return 0;
        }
      }
      if (deg[to] != deg[v]) {
        for (int to2 : g[v]) {
          if (to2 == to || to2 == 0) continue;
          if (!adj[to].count(to2)) {
            cout << 5 << '\n';
            cout << 1 << " " << to + 1 << " " << v + 1 << " " << to2 + 1 << " "
                 << to + 1 << " " << n << '\n';
            return 0;
          }
        }
      }
    }
  }
  cout << -1 << '\n';
  return 0;
}
