#include <bits/stdc++.h>
using namespace std;
const int maxN = 3e5 + 9;
array<unordered_set<int>, maxN> path;
array<bool, maxN> used;
array<vector<int>, maxN> h;
array<bool, maxN> t;
vector<int> cnt;
int ecnt = 0;
void dfs(int a) {
  cnt.push_back(a);
  t[a] = true;
  for (auto b : path[a]) {
    if (!t[b]) {
      dfs(b);
    }
    if (b < a) {
      ecnt++;
    }
  }
}
array<int, maxN> here;
vector<int> good;
bool find_path(int a, int b) {
  here[a] = true;
  good.push_back(a);
  if (a == b) {
    return true;
  }
  for (auto c : path[a]) {
    if (!here[c]) {
      auto now = find_path(c, b);
      if (now) {
        return true;
      }
    }
  }
  good.pop_back();
  return false;
}
void bfs(int n) {
  queue<int> q;
  q.push(0);
  used[0] = true;
  h[0].push_back(0);
  while (!q.empty()) {
    int a = q.front();
    q.pop();
    if (path[a].count(n - 1) > 0) {
      cout << h[a].size() << '\n';
      for (auto b : h[a]) {
        cout << b + 1 << ' ';
      }
      cout << n << endl;
      return;
    }
    if (h[a].size() == 3) {
      cout << 4 << '\n';
      for (auto b : h[a]) {
        cout << b + 1 << ' ';
      }
      cout << 1 << ' ' << n << endl;
      return;
    }
    for (auto b : path[a]) {
      if (!used[b]) {
        q.push(b);
        used[b] = true;
        h[b] = h[a];
        h[b].push_back(b);
      }
    }
  }
  vector<int> vt;
  for (int i = 0; i < n; i++) {
    if (h[i].size() == 2) {
      vt.push_back(i);
      path[i].erase(0);
    }
  }
  for (auto b : vt) {
    cnt.clear();
    ecnt = 0;
    if (!t[b]) {
      dfs(b);
    }
    long long c = cnt.size();
    if (c * (c - 1) / 2 > ecnt) {
      for (auto q : cnt) {
        if ((int)path[q].size() < (int)cnt.size() - 1) {
          unordered_set<int> was;
          for (auto e : path[q]) {
            was.insert(e);
          }
          for (auto w : cnt) {
            if (w == q) {
              continue;
            }
            if (!was.count(w)) {
              find_path(q, w);
              while (good.size() > 3) {
                if (path[good[(int)good.size() - 2]].count(q) == 0) {
                  good.pop_back();
                } else {
                  break;
                }
              }
              cout << 5 << '\n';
              cout << 1 << ' ' << q + 1 << ' ' << good[(int)good.size() - 2] + 1
                   << ' ' << good.back() + 1 << ' ' << q + 1 << ' ' << n
                   << endl;
              return;
            }
          }
        }
      }
    }
  }
  cout << -1 << endl;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    path[u].insert(v);
    path[v].insert(u);
  }
  bfs(n);
}
