#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const int MOD = 1000 * 1000 * 1000 + 7;
const long long LINF = MOD * (long long)MOD;
int n;
int m;
set<int> g[400000];
vector<int> ans1;
vector<int> ans2;
int p[400000];
vector<int> q;
void bfs() {
  int qh = 0;
  q.push_back(0);
  p[0] = -2;
  for (int i = (1); i < (n); i++) p[i] = -1;
  while (qh != q.size()) {
    int v = q[qh++];
    for (__typeof(g[v].begin()) it = g[v].begin(); it != g[v].end(); it++)
      if (p[*it] == -1) {
        p[*it] = v;
        q.push_back(*it);
        if (*it == n - 1) {
          v = n - 1;
          while (v != 0) {
            ans1.push_back(v);
            v = p[v];
          }
          ans1.push_back(0);
          return;
        }
      }
  }
}
set<int> v1, v2;
long long numedge1 = 0, numedge2 = 0;
vector<pair<int, int> > edd;
void dfs(int v) {
  p[v] = 0;
  if (g[v].count(0))
    v1.insert(v);
  else
    v2.insert(v);
  numedge1 += g[v].size();
  for (__typeof(g[v].begin()) it = g[v].begin(); it != g[v].end(); it++) {
    if (p[*it] == -2) {
      numedge2++;
      numedge1--;
    }
    if (p[*it] == -1) {
      edd.push_back(make_pair(v, *it));
      dfs(*it);
    }
  }
}
set<int> q1, q2;
void bfs2() {
  p[0] = -2;
  for (int i = (1); i < (n); i++) p[i] = -1;
  for (__typeof(g[0].begin()) it = g[0].begin(); it != g[0].end(); it++) {
    if (p[*it] == -1) {
      v1.clear();
      v2.clear();
      edd.clear();
      numedge1 = numedge2 = 0;
      dfs(*it);
      if (v2.size()) {
        for (int i = (0); i < (edd.size()); i++) {
          if (v1.count(edd[i].first) + v1.count(edd[i].second) == 1) {
            int f1 = edd[i].first, f2 = edd[i].second;
            if (v1.count(edd[i].first) == 0) swap(f1, f2);
            ans2.clear();
            ans2.push_back(n - 1);
            ans2.push_back(0);
            ans2.push_back(f2);
            ans2.push_back(f1);
            ans2.push_back(0);
            return;
          }
        }
      } else {
        long long nv = v1.size() + v2.size();
        if (nv * (nv - 1) != numedge1 && !ans2.size()) {
          for (__typeof(v1.begin()) it = v1.begin(); it != v1.end(); it++)
            if (g[*it].size() != nv) {
              int V = *it;
              q1.clear();
              q2.clear();
              for (__typeof(v1.begin()) it2 = v1.begin(); it2 != v1.end();
                   it2++) {
                int U = *it2;
                if (U != V) {
                  if (g[V].count(U))
                    q1.insert(U);
                  else
                    q2.insert(U);
                }
              }
              for (__typeof(v1.begin()) it1 = v1.begin(); it1 != v1.end();
                   it1++)
                for (__typeof(g[*it1].begin()) it2 = g[*it1].begin();
                     it2 != g[*it1].end(); it2++) {
                  int qwe1 = *it1;
                  int qwe2 = *it2;
                  if (qwe1 == 0 || qwe2 == 0) continue;
                  if (qwe1 == V || qwe2 == V) continue;
                  {
                    if (q1.count(qwe1) + q1.count(qwe2) == 1) {
                      int f1 = qwe1, f2 = qwe2;
                      if (q1.count(qwe1) == 0) swap(f1, f2);
                      ans2.clear();
                      ans2.push_back(n - 1);
                      ans2.push_back(V);
                      ans2.push_back(f2);
                      ans2.push_back(f1);
                      ans2.push_back(V);
                      ans2.push_back(0);
                      break;
                    }
                  }
                }
              break;
            }
        }
      }
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (0); i < (m); i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    b--;
    g[a].insert(b);
    g[b].insert(a);
  }
  bfs();
  bfs2();
  if (ans1.size() == 0) ans1 = ans2;
  if (ans2.size() > 0 && ans1.size() > ans2.size()) ans1 = ans2;
  if (ans1.size() == 0)
    cout << -1;
  else {
    cout << ans1.size() - 1 << "\n";
    reverse(ans1.begin(), ans1.end());
    for (int i = (0); i < (ans1.size()); i++) {
      cout << ans1[i] + 1 << " ";
    }
  }
  return 0;
}
