#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
vector<int> edges[N];
set<int> record[N];
int n, m;
bool bfs() {
  queue<int> q;
  q.push(1);
  vector<pair<int, int>> dist(n + 1, {-1, -1});
  dist[1] = {0, 0};
  while (!q.empty()) {
    int cur = q.front();
    q.pop();
    for (int next : edges[cur]) {
      if (dist[next].first == -1) {
        dist[next].first = dist[cur].first + 1;
        dist[next].second = cur;
        q.push(next);
      }
    }
  }
  if (dist[n].first > 0 && dist[n].first <= 4) {
    cout << dist[n].first << endl;
    int cur = n;
    vector<int> ans;
    while (cur != 0) {
      ans.push_back(cur);
      cur = dist[cur].second;
    }
    for (int i = ans.size() - 1; i >= 0; i -= 1) cout << ans[i] << " ";
    cout << endl;
    return true;
  } else {
    for (int i = 1; i <= n; i += 1) {
      if (dist[i].first == 2) {
        cout << 4 << endl;
        cout << 1 << " " << dist[i].second << " " << i << " 1 " << n << endl;
        return true;
      }
    }
  }
  return false;
}
void dfs(int root, vector<bool> &flag, vector<pair<int, int>> &mm) {
  flag[root] = false;
  pair<int, int> cur{root, edges[root].size()};
  for (int next : edges[root]) {
    if (next == 1) cur.second -= 1;
    if (flag[next]) dfs(next, flag, mm);
  }
  mm.push_back(cur);
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i += 1) {
    int u, v;
    cin >> u >> v;
    edges[u].push_back(v);
    edges[v].push_back(u);
    record[u].insert(v);
    record[v].insert(u);
  }
  if (bfs()) return 0;
  vector<bool> flag(n + 1, true);
  flag[1] = false;
  for (int cur : edges[1]) {
    if (!flag[cur]) continue;
    vector<pair<int, int>> mm;
    dfs(cur, flag, mm);
    for (int i = 0; i < mm.size(); i += 1) {
      if (mm[i].second + 1 < mm.size()) {
        int x = mm[i].first;
        for (int y : edges[x]) {
          if (y == 1) continue;
          for (int z : edges[y]) {
            if (z != 1 && z != x && record[z].count(x) == 0) {
              cout << 5 << endl;
              cout << "1 " << x << " " << y << " " << z << " " << x << " " << n
                   << endl;
              return 0;
            }
          }
        }
      }
    }
  }
  cout << -1 << endl;
}
