#include <bits/stdc++.h>
using namespace std;
const int maxn = 333333;
const int INF = 0x3f3f3f3f;
vector<int> e[maxn];
int pre[maxn];
vector<int> path;
int ans = INF;
int n, m;
int Solve1() {
  int dep[maxn];
  bool vis[maxn];
  memset(pre, -1, sizeof pre);
  memset(dep, INF, sizeof dep);
  memset(vis, 0, sizeof vis);
  queue<int> q;
  pre[1] = 1;
  dep[1] = 0;
  vis[1] = 1;
  q.push(1);
  while (q.size()) {
    int u = q.front();
    q.pop();
    vis[u] = 0;
    for (int i = 0; i < e[u].size(); ++i) {
      int v = e[u][i];
      if (dep[v] > dep[u] + 1) {
        dep[v] = dep[u] + 1;
        pre[v] = u;
        if (!vis[v] && v != n) {
          q.push(v);
          vis[v] = 1;
        }
      }
    }
  }
  return dep[n];
}
int Find2(int s) {
  int dep[maxn];
  bool vis[maxn];
  set<int> node2;
  memset(pre, -1, sizeof pre);
  memset(dep, INF, sizeof dep);
  memset(vis, 0, sizeof vis);
  dep[1] = -1;
  queue<int> q;
  pre[s] = 1;
  dep[s] = 0;
  vis[s] = 1;
  q.push(s);
  while (q.size()) {
    int u = q.front();
    q.pop();
    vis[u] = 0;
    for (int i = 0; i < e[u].size(); ++i) {
      int v = e[u][i];
      if (dep[v] > dep[u] + 1) {
        dep[v] = dep[u] + 1;
        pre[v] = u;
        if (dep[v] == 2) {
          node2.insert(v);
          continue;
        }
        if (!vis[v] && v != n) {
          q.push(v);
          vis[v] = 1;
        }
      }
    }
  }
  for (int i = 0; i < e[s].size(); ++i) {
    int v = e[s][i];
    if (node2.count(v)) node2.erase(v);
  }
  return node2.size() > 0 ? *node2.begin() : -1;
}
void OutputByPre1() {
  int x = n;
  vector<int> tmp;
  while (x != 1) {
    tmp.push_back(x);
    x = pre[x];
  }
  tmp.push_back(1);
  reverse(tmp.begin(), tmp.end());
  cout << tmp.size() - 1 << endl;
  for (int i = 0; i < tmp.size(); ++i) {
    if (i) cout << ' ';
    cout << tmp[i];
  }
  cout << endl;
}
void OutputByPre2(int v, int s, bool flag) {
  int x = v;
  vector<int> tmp;
  tmp.push_back(n);
  tmp.push_back(s);
  while (x != 1) {
    tmp.push_back(x);
    x = pre[x];
  }
  tmp.push_back(1);
  reverse(tmp.begin(), tmp.end());
  if (flag) {
    path = tmp;
    return;
  }
  cout << tmp.size() - 1 << endl;
  for (int i = 0; i < tmp.size(); ++i) {
    if (i) cout << ' ';
    cout << tmp[i];
  }
  cout << endl;
}
int IsClique(int s) {
  int sz = e[s].size() - 1;
  int dep[maxn];
  bool vis[maxn];
  memset(vis, 0, sizeof vis);
  queue<int> q;
  pre[s] = 1;
  vis[s] = 1;
  int tmp;
  while (q.size()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < e[u].size(); ++i) {
      int v = e[u][i];
      if (!vis[v]) {
        if (e[v].size() < sz) {
          tmp = Find2(v);
          if (tmp != -1) {
            OutputByPre2(tmp, v, 1);
            return v;
          }
        }
        vis[v] = 1;
        q.push(v);
      }
    }
  }
  return -1;
}
bool Solve2() {
  int tmp = Find2(1);
  if (tmp != -1) {
    OutputByPre2(tmp, 1, 0);
    return true;
  } else {
    for (int i = 0; i < e[1].size(); ++i) {
      int v = e[1][i];
      tmp = Find2(v);
      if (tmp != -1) {
        OutputByPre2(tmp, v, 0);
        return true;
      }
      if (path.size() > 0) continue;
      IsClique(v);
    }
  }
  if (path.size()) {
    cout << path.size() - 1 << endl;
    for (int i = 0; i < path.size(); ++i) {
      if (i) cout << ' ';
      cout << path[i];
    }
    cout << endl;
    return true;
  }
  return false;
}
int main() {
  int u, v;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    cin >> u >> v;
    e[u].push_back(v);
    e[v].push_back(u);
  }
  ans = Solve1();
  if (ans <= 4) {
    OutputByPre1();
  } else {
    if (!Solve2()) {
      cout << -1 << endl;
    }
  }
}
