#include <bits/stdc++.h>
using namespace std;
const int oo = 1e9;
const int maxn = 3e5 + 1;
int n, m, d[maxn], trade[maxn];
vector<int> e[maxn];
void Enter() {
  cin >> n >> m;
  for (int m2 = m; m2 > 0; --m2) {
    int u, v;
    cin >> u >> v;
    e[u].push_back(v);
    e[v].push_back(u);
  }
}
void Init() {}
void BFS(int s) {
  queue<int> qu;
  fill(d, d + n + 1, +oo);
  fill(trade, trade + n + 1, 0);
  d[1] = d[s] = 0;
  qu.push(s);
  while (!qu.empty()) {
    int u = qu.front();
    qu.pop();
    for (int v : e[u])
      if (d[v] == +oo) {
        d[v] = d[u] + 1;
        trade[v] = u;
        qu.push(v);
      }
  }
}
void Print(int v) {
  if (v == 0) return;
  Print(trade[v]);
  cout << v << ' ';
}
void Solve() {
  BFS(1);
  if (d[n] <= 4) {
    cout << d[n] << '\n';
    Print(n);
    return;
  }
  for (int i = 1; i <= n; ++i)
    if (d[i] == 2) {
      cout << d[i] + 2 << '\n';
      cout << 1 << ' ' << trade[i] << ' ' << i << ' ' << 1 << ' ' << n;
      return;
    }
  bool ban[n + 1];
  fill(ban, ban + n + 1, 0);
  for (int v : e[n]) ban[v] = 1;
  vector<int> can;
  for (int i : e[1])
    if (!ban[i]) can.push_back(i);
  for (int test = 1; can.size() != 0; ++test) {
    int id = rand() % can.size();
    int s = can[id];
    can[id] = can.back();
    can.pop_back();
    BFS(s);
    for (int i = 1; i <= n; ++i)
      if (d[i] == 2) {
        cout << 5 << '\n';
        cout << 1 << ' ';
        Print(i);
        cout << s << ' ' << n;
        return;
      }
  }
  if (d[n] != +oo) {
    cout << d[n] << '\n';
    Print(n);
    return;
  }
  cout << -1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  srand(time(NULL));
  Enter();
  Init();
  Solve();
}
