#include <bits/stdc++.h>
using namespace std;
int const MAX = 3e5 + 41;
int n, m;
unordered_set<int> e[MAX];
int d[MAX];
int f[MAX];
void bfs() {
  deque<int> deq;
  memset(d, 255, sizeof(d));
  d[1] = 0;
  deq.push_back(1);
  while ((int)deq.size()) {
    int x = deq.front();
    deq.pop_front();
    for (int y : e[x]) {
      if (d[y] != -1) continue;
      d[y] = d[x] + 1;
      f[y] = x;
      deq.push_back(y);
    }
  }
}
vector<int> st;
int u[MAX];
void dfs(int x) {
  u[x] = 1;
  st.push_back(x);
  for (int y : e[x]) {
    if (u[y]) continue;
    if (y == 1) continue;
    dfs(y);
  }
}
bool checkclique() {
  for (int x : st) {
    while (false) {
    };
  }
  while (false) {
  };
  long long m = (int)st.size();
  for (int x : st) {
    m += (int)e[x].size();
  }
  int n = (int)st.size();
  while (false) {
  };
  if (m == (long long)n * (n - 1)) {
    return true;
  }
  return false;
}
void solve() {
  bfs();
  if (d[n] != -1 && d[n] <= 4) {
    vector<int> ans;
    int x = n;
    while (1) {
      ans.push_back(x);
      if (x == 1) break;
      x = f[x];
    }
    printf("%d\n", (int)ans.size() - 1);
    for (int i = (int)ans.size() - 1; i >= 0; i--) {
      printf("%d ", ans[i]);
    }
    return;
  }
  int x = -1;
  for (int i = 1; i <= n; i++) {
    if (d[i] == 2) {
      x = i;
    }
  }
  if (x != -1) {
    vector<int> ans;
    ans.push_back(1);
    ans.push_back(f[x]);
    ans.push_back(x);
    ans.push_back(1);
    ans.push_back(n);
    printf("%d\n", (int)ans.size() - 1);
    for (int i = 0; i <= (int)ans.size() - 1; i++) {
      printf("%d ", ans[i]);
    }
    return;
  }
  if (d[n] != -1 && d[n] <= 5) {
    vector<int> ans;
    int x = n;
    while (1) {
      ans.push_back(x);
      if (x == 1) break;
      x = f[x];
    }
    printf("%d\n", (int)ans.size() - 1);
    for (int i = (int)ans.size() - 1; i >= 0; i--) {
      printf("%d ", ans[i]);
    }
    return;
  }
  for (int x : e[1]) {
    if (u[x]) continue;
    st.clear();
    dfs(x);
    if (!checkclique()) {
      int y = -1;
      for (int z : st) {
        if (y == -1 || ((int)e[y].size() < (int)e[z].size())) {
          y = z;
        }
      }
      assert(y != -1);
      for (int z : e[y]) {
        for (int o : e[y]) {
          if (z == o) continue;
          if (e[z].find(o) == e[z].end()) {
            vector<int> ans;
            ans.push_back(1);
            ans.push_back(o);
            ans.push_back(y);
            ans.push_back(z);
            ans.push_back(o);
            ans.push_back(n);
            printf("%d\n", (int)ans.size() - 1);
            for (int ver : ans) {
              printf("%d ", ver);
            }
            return;
          }
        }
      }
    }
  }
  printf("-1\n");
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    e[x].insert(y);
    e[y].insert(x);
  }
  solve();
  return 0;
}
