#include <bits/stdc++.h>
using namespace std;
const int maxN = 3e5 + 10;
int n, m, cnt[maxN], pre[maxN];
unsigned long long num[maxN], a[maxN];
set<int> E[maxN];
void BFS(int u) {
  cnt[u] = 1;
  queue<int> q;
  q.push(u);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int v : E[u])
      if (!cnt[v]) {
        pre[v] = u;
        cnt[v] = cnt[u] + 1;
        q.push(v);
      }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int u, v;
    cin >> u >> v;
    E[u].insert(v);
    E[v].insert(u);
  }
  num[0] = 1;
  for (int i = 1; i <= n; ++i) {
    num[i] = num[i - 1] * 1000000007;
    E[i].insert(i);
  }
  for (int u = 1; u <= n; ++u)
    for (int v : E[u]) a[u] += num[v];
  BFS(1);
  if (cnt[n] && cnt[n] <= 5) {
    cout << cnt[n] - 1 << "\n";
    vector<int> ans;
    while (n != 1) {
      ans.push_back(n);
      n = pre[n];
    }
    ans.push_back(1);
    reverse(ans.begin(), ans.end());
    for (int v : ans) cout << v << " ";
    return 0;
  }
  for (int i = 1; i <= n; ++i)
    if (cnt[i] == 3) {
      cout << 4 << "\n"
           << 1 << " " << pre[i] << " " << i << " " << 1 << " " << n;
      return 0;
    }
  for (int u : E[1])
    for (int v : E[u])
      if (u != 1 && v != 1 && a[u] != a[v]) {
        cout << 5 << "\n";
        for (int i : E[u])
          if (!E[v].count(i)) {
            cout << 1 << " " << v << " " << u << " " << i << " " << v << " "
                 << n;
            return 0;
          }
        for (int i : E[v])
          if (!E[u].count(i)) {
            cout << 1 << " " << u << " " << v << " " << i << " " << u << " "
                 << n;
            return 0;
          }
      }
  cout << -1 << "\n";
}
