#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d%d", &(n), &(m));
  map<int, set<int>> oc;
  for (int i = 0; i < (m); ++i) {
    int u, v;
    scanf("%d%d", &(u), &(v));
    u--;
    v--;
    if (!oc.count(u)) {
      oc[u] = set<int>();
    }
    oc[u].insert(v);
    if (!oc.count(v)) {
      oc[v] = set<int>();
    }
    oc[v].insert(u);
  }
  if (!oc.count(0)) {
    printf("-1\n");
    return 0;
  }
  vector<int> visited(n, -1);
  queue<pair<int, pair<int, int>>> tovisit;
  tovisit.push({0, {0, 0}});
  int haslvl2 = 0;
  while (!tovisit.empty() and tovisit.front().second.second <= 3) {
    pair<int, pair<int, int>> tv = tovisit.front();
    if (!~visited[tv.first]) {
      if (tv.second.second == 2) {
        haslvl2 = tv.first;
      }
      visited[tv.first] = tv.second.first;
      if (oc.count(tv.first) and tv.second.second < 3) {
        for (auto i : oc[tv.first]) {
          tovisit.push({i, {tv.first, tv.second.second + 1}});
        }
      }
    }
    tovisit.pop();
  }
  if (~visited[n - 1]) {
    vector<int> vis(1, n - 1);
    int curr = n - 1;
    while (curr) {
      curr = visited[curr];
      vis.push_back(curr);
    }
    printf("%d\n", vis.size() - 1);
    for (int i = vis.size() - 1; ~i; i--) {
      printf("%d%c", vis[i] + 1, i ? ' ' : '\n');
    }
    return 0;
  }
  if (haslvl2) {
    printf("4\n");
    printf("1 %d %d 1 %d", visited[haslvl2] + 1, haslvl2 + 1, n);
    return 0;
  }
  vector<bool> dejateste(n, false);
  dejateste[0] = true;
  for (auto ca : oc[0]) {
    if (!dejateste[ca]) {
      dejateste[ca] = true;
      int A, B, C;
      for (auto j : oc[ca]) {
        if (j) {
          auto ita = oc[ca].begin();
          auto itb = oc[j].begin();
          int arediff = 0;
          while (true) {
            if (ita != oc[ca].end() and *ita == j) {
              ita++;
            }
            if (itb != oc[j].end() and *itb == ca) {
              itb++;
            }
            if (ita == oc[ca].end() and itb == oc[j].end()) {
              break;
            }
            if (ita == oc[ca].end() and itb != oc[j].end()) {
              arediff = *itb;
              A = ca;
              B = j;
              C = arediff;
              assert(arediff);
              break;
            }
            if (ita != oc[ca].end() and itb == oc[j].end()) {
              arediff = *ita;
              A = j;
              B = ca;
              C = arediff;
              assert(arediff);
              break;
            }
            if (ita != oc[ca].end() and itb != oc[j].end() and *ita != *itb) {
              arediff = min(*ita, *itb);
              A = *ita < *itb ? j : ca;
              B = ca + j - A;
              C = arediff;
              assert(arediff);
              break;
            }
            ita++;
            itb++;
          }
          dejateste[j] = true;
          if (arediff) {
            printf("5\n");
            printf("1 %d %d %d %d %d", A + 1, B + 1, C + 1, A + 1, n);
            return 0;
          }
        }
      }
    }
  }
  printf("-1\n");
  return 0;
}
