#include <bits/stdc++.h>
using namespace std;
const int maxn = 300001;
vector<int> adj[maxn];
int dis[maxn];
bool vis[maxn];
int p[maxn];
bool con[maxn];
set<int> s;
void dfs(int u);
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  queue<int> q;
  q.push(1);
  dis[1] = 1;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < adj[u].size(); i++) {
      int v = adj[u][i];
      if (dis[v]) continue;
      q.push(v);
      dis[v] = dis[u] + 1;
      p[v] = u;
    }
  }
  int ans0 = 0;
  stack<int> ans;
  if (dis[n]) {
    int cur = n;
    ans0 = dis[n] - 1;
    while (p[cur]) {
      ans.push(cur);
      cur = p[cur];
    }
  }
  if (ans0 && ans0 <= 4) {
    printf("%d\n", ans0);
    printf("1 ");
    while (!ans.empty()) {
      printf("%d ", ans.top());
      ans.pop();
    }
    return 0;
  }
  for (int i = 0; i < adj[1].size(); i++) {
    con[adj[1][i]] = 1;
  }
  for (int i = 0; i < adj[1].size(); i++) {
    int u = adj[1][i];
    for (int j = 0; j < adj[u].size(); j++) {
      int v = adj[u][j];
      if (v == 1) continue;
      if (!con[v]) {
        printf("4\n1 %d %d 1 %d", u, v, n);
        return 0;
      }
    }
  }
  if (ans0 && ans0 <= 5) {
    printf("%d\n", ans0);
    printf("1 ");
    while (!ans.empty()) {
      printf("%d ", ans.top());
      ans.pop();
    }
    return 0;
  }
  for (int i = 0; i < adj[1].size(); i++) {
    int u = adj[1][i];
    if (vis[u]) continue;
    s.clear();
    dfs(u);
    int sz = s.size();
    int cur = 0;
    for (set<int>::iterator it = s.begin(); it != s.end(); it++) {
      int v = *it;
      if (adj[v].size() != sz) {
        cur = v;
        break;
      }
    }
    if (cur) {
      queue<int> q;
      memset(dis, 0, sizeof(dis));
      dis[cur] = 1;
      q.push(cur);
      p[cur] = 0;
      while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (int i = 0; i < adj[u].size(); i++) {
          int v = adj[u][i];
          if (dis[v] || v == 1) continue;
          dis[v] = dis[u] + 1;
          q.push(v);
          p[v] = u;
        }
      }
      int cur2 = 0;
      for (set<int>::iterator it = s.begin(); it != s.end(); it++) {
        if (dis[*it] == 3) cur2 = *it;
      }
      printf("5\n1 %d %d %d %d %d", cur, p[cur2], cur2, cur, n);
      return 0;
    }
  }
  if (ans0) {
    printf("%d\n", ans0);
    printf("1 ");
    while (!ans.empty()) {
      printf("%d ", ans.top());
      ans.pop();
    }
    return 0;
  }
  printf("-1");
  return 0;
}
void dfs(int u) {
  vis[u] = 1;
  s.insert(u);
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (vis[v] || v == 1) continue;
    dfs(v);
  }
}
