#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
const int logn = log2(maxn) + 1;
int n, m;
vector<int> adj[maxn];
int vis[maxn];
int cnt = 0;
int trace[maxn];
void BFS() {
  queue<int> q;
  q.push(1);
  memset(vis, -1, sizeof vis);
  vis[1] = 0;
  while (q.size()) {
    int u = q.front();
    q.pop();
    for (int c : adj[u]) {
      if (vis[c] == -1) {
        vis[c] = vis[u] + 1;
        trace[c] = u;
        q.push(c);
      }
    }
  }
}
unsigned long long can[maxn];
unsigned long long r[maxn];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  if (fopen("A"
            ".INP",
            "r")) {
    freopen(
        "A"
        ".INP",
        "r", stdin);
    freopen(
        "A"
        ".OUT",
        "w", stdout);
  }
  srand(time(0));
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    r[i] = (unsigned long long)rand() * rand() * rand() / 2 * rand();
    can[i] = r[i];
  }
  for (int i = 1; i <= m; ++i) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
    can[u] += r[v];
    can[v] += r[u];
  }
  for (int i = 1; i <= n; ++i) {
    sort(adj[i].begin(), adj[i].end());
  }
  BFS();
  if (vis[n] != -1 && vis[n] <= 4) {
    vector<int> res;
    while (n != 0) {
      res.push_back(n);
      n = trace[n];
    }
    cout << res.size() - 1 << endl;
    for (int i = res.size() - 1; i >= 0; --i) cout << res[i] << " ";
    exit(0);
  }
  for (int i = 1; i <= n; ++i) {
    if (vis[i] == 2) {
      cout << 4 << endl;
      cout << 1 << " " << trace[i] << " " << i << " " << 1 << " " << n;
      exit(0);
    }
  }
  for (int u1 : adj[1]) {
    for (int u2 : adj[u1]) {
      if (u2 != 1 && u2 != u1 && can[u1] != can[u2]) {
        cout << 5 << endl;
        for (int c : adj[u2]) {
          if (c != u1 &&
              binary_search(adj[u1].begin(), adj[u1].end(), c) == 0) {
            cout << 1 << " " << u1 << " " << u2 << " " << c << " " << u1 << " "
                 << n;
            exit(0);
          }
        }
        swap(u1, u2);
        for (int c : adj[u2]) {
          if (c != u1 &&
              binary_search(adj[u1].begin(), adj[u1].end(), c) == 0) {
            cout << 1 << " " << u1 << " " << u2 << " " << c << " " << u1 << " "
                 << n;
            exit(0);
          }
        }
      }
    }
  }
  cout << -1;
}
