#include <bits/stdc++.h>
using namespace std;
class Solution {
 public:
  vector<int> escape(vector<vector<int>>& graph) {
    int n = graph.size();
    for (auto& v : graph) {
      sort(v.begin(), v.end());
    }
    vector<int> res;
    res = bfs(graph);
    if (!res.empty() && res.size() <= 5) {
      return res;
    }
    pair<int, int> p = search(graph, 0);
    if (p.first != -1) {
      res = vector<int>{0, p.first, p.second, 0, n - 1};
      return res;
    }
    if (!res.empty() && res.size() <= 6) {
      return res;
    }
    disconnect(graph, 0);
    vector<int> path = search2(graph, 0);
    if (path.size() > 0) {
      return vector<int>{0, path[0], path[1], path[2], path[0], n - 1};
    }
    return {};
  }

 private:
  vector<int> bfs(const vector<vector<int>>& graph) {
    int n = graph.size();
    vector<bool> visited(n, false);
    vector<int> pre(n, -1);
    queue<int> q;
    q.push(0);
    visited[0] = true;
    while (!q.empty()) {
      auto u = q.front();
      q.pop();
      for (auto v : graph[u]) {
        if (!visited[v]) {
          visited[v] = true;
          q.push(v);
          pre[v] = u;
          if (v == n - 1) {
            break;
          }
        }
      }
    }
    if (pre[n - 1] == -1) {
      return {};
    }
    vector<int> res;
    int v = n - 1;
    do {
      res.push_back(v);
      v = pre[v];
    } while (v != -1);
    reverse(res.begin(), res.end());
    return res;
  }
  pair<int, int> search(const vector<vector<int>>& graph, int s) {
    for (auto u : graph[s]) {
      if (u == 0) {
        continue;
      }
      for (auto v : graph[u]) {
        if (v == s) {
          continue;
        }
        auto it = lower_bound(graph[s].begin(), graph[s].end(), v);
        if (it == graph[s].end() || *it != v) {
          return make_pair(u, v);
        }
      }
    }
    return make_pair(-1, -1);
  }
  void disconnect(vector<vector<int>>& graph, int s) {
    for (auto v : graph[s]) {
      int n = graph[v].size();
      int m = 0;
      for (int i = 0; i < n; ++i) {
        if (graph[v][i] != s) {
          graph[v][m++] = graph[v][i];
        }
      }
      graph[v].resize(m);
    }
  }
  vector<int> search2(const vector<vector<int>>& graph, int s) {
    int n = graph.size();
    vector<bool> visited(n, false);
    visited[s] = true;
    for (auto u : graph[s]) {
      if (visited[u]) {
        continue;
      }
      vector<int> q;
      q.push_back(u);
      visited[u] = true;
      for (int i = 0; i < q.size(); ++i) {
        u = q[i];
        for (auto v : graph[u]) {
          if (!visited[v]) {
            visited[v] = true;
            q.push_back(v);
          }
        }
      }
      for (auto v : q) {
        if (graph[v].size() < q.size() - 1) {
          unordered_set<int> nodes(graph[v].begin(), graph[v].end());
          for (auto y : nodes) {
            for (auto x : graph[y]) {
              if (x != v && nodes.count(x) == 0) {
                return vector<int>{x, y, v};
              }
            }
          }
        }
      }
    }
    return {};
  }
};
int main(int argc, char** argv) {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<vector<int>> graph(n);
  int i = m;
  while (i-- > 0) {
    int u, v;
    scanf("%d%d", &u, &v);
    graph[u - 1].push_back(v - 1);
    graph[v - 1].push_back(u - 1);
  }
  Solution sol;
  vector<int> res = sol.escape(graph);
  if (res.empty()) {
    printf("%d\n", -1);
  } else {
    printf("%lu\n", res.size() - 1);
    for (auto num : res) {
      printf("%d ", num + 1);
    }
    printf("\n");
  }
  return 0;
}
