#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int n, m, x, y, sz, a[N];
bool used[N];
vector<int> q[N];
inline bool f(int x, int y) {
  return binary_search(q[x].begin(), q[x].end(), y);
}
void dfs1(int v) {
  used[v] = true;
  sz++;
  for (int to : q[v]) {
    if (!used[to]) {
      dfs1(to);
    }
  }
}
void dfs2(int v) {
  a[v] = sz;
  for (int to : q[v]) {
    if (!a[to]) {
      dfs2(to);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> x >> y;
    q[x].push_back(y);
    q[y].push_back(x);
  }
  if (q[1].empty()) {
    return cout << "-1", 0;
  }
  for (int i = 1; i <= n; i++) {
    sort(q[i].begin(), q[i].end());
  }
  if (f(1, n)) {
    return cout << "1\n" << 1 << " " << n, 0;
  }
  for (int x : q[1]) {
    if (f(x, n)) {
      return cout << "2\n" << 1 << " " << x << " " << n, 0;
    }
  }
  for (int x : q[1]) {
    for (int y : q[x]) {
      if (f(y, n)) {
        return cout << "3\n" << 1 << " " << x << " " << y << " " << n, 0;
      }
    }
  }
  for (int x : q[1]) {
    for (int y : q[x]) {
      if (y != 1 && !f(1, y)) {
        return cout << "4\n"
                    << 1 << " " << x << " " << y << " " << 1 << " " << n,
               0;
      }
    }
  }
  a[1] = used[1] = true;
  for (int x : q[1]) {
    if (!used[x]) {
      sz = 0;
      dfs1(x);
      dfs2(x);
    }
  }
  int mn = 2e9, cur = -1;
  for (int i : q[1]) {
    if (a[i] != q[i].size() && q[i].size() < mn) {
      mn = q[i].size();
      cur = i;
    }
  }
  if (cur == -1) {
    return cout << "-1", 0;
  }
  for (int x : q[cur]) {
    if (x != 1) {
      for (int y : q[x]) {
        if (y != 1 && y != cur && !f(cur, y)) {
          return cout << "5\n"
                      << 1 << " " << cur << " " << x << " " << y << " " << cur
                      << " " << n,
                 0;
        }
      }
    }
  }
  cout << "-1";
}
