#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> g[300030];
map<pair<int, int>, bool> ed;
const int inf = 1e9;
int d[300030];
int pa[300030];
bool f[300030], vis[300030];
vector<int> first_solve() {
  vector<int> ans;
  for (int x : g[1]) f[x] = 1;
  for (int x : g[1]) {
    for (int y : g[x]) {
      if (y != 1 && !f[y]) {
        ans = {1, x, y, 1, n};
        for (int x : g[1]) f[x] = 0;
        return ans;
      }
    }
  }
  for (int x : g[1]) f[x] = 0;
  return {};
}
vector<int> second_solve() {
  vector<int> ans;
  vis[1] = 1;
  for (int i : g[1])
    if (!vis[i]) {
      vis[i] = 1;
      for (int j : g[i]) {
        if (j == 1) continue;
        vis[j] = 1;
        f[j] = 1;
      }
      for (int j : g[i]) {
        if (j == 1) continue;
        for (int k : g[j]) {
          if (k == i) continue;
          if (k != 1 && !f[k]) {
            return {1, i, j, k, i, n};
          }
        }
      }
      for (int j : g[i]) {
        if (j == 1) continue;
        for (int k : g[i]) {
          if (k == 1) continue;
          if (k == j) continue;
          if (!ed[make_pair(j, k)]) {
            return {1, j, i, k, j, n};
          }
        }
      }
    }
  return {};
}
int main() {
  scanf("%d%d", &n, &m);
  int u, v;
  while (m--) {
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
    ed[make_pair(u, v)] = 1;
    ed[make_pair(v, u)] = 1;
  }
  for (int i = 2; i <= n; i++) d[i] = inf;
  d[1] = 0;
  queue<int> Q;
  Q.push(1);
  while (!Q.empty()) {
    int x = Q.front();
    Q.pop();
    for (int y : g[x]) {
      if (d[y] == inf) {
        d[y] = d[x] + 1;
        pa[y] = x;
        Q.push(y);
      }
    }
  }
  vector<int> ans;
  if (d[n] < inf) {
    int now = n;
    while (1) {
      ans.push_back(now);
      now = pa[now];
      if (now == 1) break;
    }
    ans.push_back(now);
    reverse(ans.begin(), ans.end());
  }
  if (ans.empty() || ans.size() > 5) {
    vector<int> cur = first_solve();
    if (!cur.empty()) ans = cur;
  }
  if (ans.empty() || ans.size() > 6) {
    vector<int> cur = second_solve();
    if (!cur.empty()) ans = cur;
  }
  if (ans.empty()) {
    puts("-1");
  } else {
    cout << ans.size() - 1 << endl;
    for (int x : ans) cout << x << " ";
  }
}
