#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int arr = 2e5 + 10;
const int ar = 2e3 + 10;
const long double pi = acos(-1);
const long double eps = 1e-10;
const long long md = 1e9 + 7;
vector<int> reb[(int)(3e5 + 10)];
bool use[(int)(3e5 + 10)];
int n, m;
int pred[(int)(3e5 + 10)];
vector<int> ans(0);
set<pair<int, int> > edges;
void upd_ans(vector<int> cur_ans) {
  if (ans.empty() || (int)(cur_ans.size()) < (int)(ans.size())) {
    ans = cur_ans;
  }
}
void bfs() {
  queue<int> q;
  q.push(1);
  use[1] = 1;
  while (!q.empty()) {
    int now = q.front();
    q.pop();
    for (auto wh : reb[now]) {
      if (!use[wh]) {
        use[wh] = 1;
        q.push(wh);
        pred[wh] = now;
      }
    }
  }
  if (use[n]) {
    vector<int> cur_ans(0);
    int cur = n;
    while (cur != 1) {
      cur_ans.push_back(cur);
      cur = pred[cur];
    }
    cur_ans.push_back(1);
    reverse(cur_ans.begin(), cur_ans.end());
    upd_ans(cur_ans);
  }
}
int num[(int)(3e5 + 10)];
vector<int> ways[(int)(3e5 + 10)];
int cnt;
void another_algo() {
  int c1 = 0;
  for (int i = 2; i <= n; i++) {
    c1 += use[i];
  }
  if ((int)(reb[1].size()) != c1) {
    for (int i = 1; i <= n; i++) {
      if (edges.count({1, i})) {
        for (auto j : reb[i]) {
          if (j != 1 && !edges.count({1, j})) {
            vector<int> cur_ans(0);
            cur_ans.push_back(1);
            cur_ans.push_back(i);
            cur_ans.push_back(j);
            cur_ans.push_back(1);
            cur_ans.push_back(n);
            upd_ans(cur_ans);
            return;
          }
        }
      }
    }
  } else {
    for (int i = 2; i <= n; i++) {
      if (use[i]) {
        set<int> nums;
        nums.clear();
        for (auto wh : reb[i]) {
          if (num[wh]) {
            nums.insert(num[wh]);
          }
        }
        if ((int)(nums.size()) == 0) {
          num[i] = ++cnt;
          ways[cnt].push_back(i);
        } else if ((int)(nums.size()) == 1) {
          int have = -1;
          int not_have = -1;
          for (auto wh : ways[*nums.begin()]) {
            if (edges.count({i, wh})) {
              have = wh;
            } else {
              not_have = wh;
            }
          }
          if (not_have == -1) {
            num[i] = *nums.begin();
            ways[*nums.begin()].push_back(i);
          } else {
            int I = i;
            int J = have;
            int K = not_have;
            vector<int> cur_ans(0);
            cur_ans.push_back(1);
            cur_ans.push_back(I);
            cur_ans.push_back(J);
            cur_ans.push_back(K);
            cur_ans.push_back(I);
            cur_ans.push_back(n);
            upd_ans(cur_ans);
            return;
          }
        } else {
          int num1 = *nums.begin();
          nums.erase(nums.begin());
          int num2 = *nums.begin();
          nums.erase(nums.begin());
          int kek1 = -1;
          int kek2 = -1;
          for (auto wh : reb[i]) {
            if (num[wh] == num1) {
              kek1 = wh;
            }
            if (num[wh] == num2) {
              kek2 = wh;
            }
          }
          int I = kek1;
          int J = i;
          int K = kek2;
          vector<int> cur_ans(0);
          cur_ans.push_back(1);
          cur_ans.push_back(I);
          cur_ans.push_back(J);
          cur_ans.push_back(K);
          cur_ans.push_back(I);
          cur_ans.push_back(n);
          upd_ans(cur_ans);
          return;
        }
      }
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    if (min(u, v) == 1 && max(u, v) == n) {
      cout << 1 << "\n";
      cout << 1 << " " << n << "\n";
      return 0;
    }
    edges.insert({u, v});
    edges.insert({v, u});
    reb[u].push_back(v);
    reb[v].push_back(u);
  }
  bfs();
  if ((int)(ans.size()) <= 3 && !ans.empty()) {
    cout << (int)(ans.size()) - 1 << "\n";
    for (auto i : ans) {
      cout << i << " ";
    }
    cout << "\n";
    return 0;
  }
  another_algo();
  if (ans.empty()) {
    cout << -1 << "\n";
  } else {
    cout << (int)(ans.size()) - 1 << "\n";
    for (auto i : ans) {
      cout << i << " ";
    }
    cout << "\n";
  }
}
