#include <bits/stdc++.h>
using namespace std;
const int maxn = 600;
int adj[maxn][maxn];
int n, m, tot = 0;
int q[maxn * maxn][3], A[maxn * maxn], B[maxn * maxn];
int pre[maxn][maxn][3], u[maxn][maxn], deg[maxn];
int print(int x, int y) {
  if (pre[x][y][1]) print(pre[x][y][1], pre[x][y][2]);
  A[++tot] = x;
  B[tot] = y;
}
int main() {
  cin >> n >> m;
  memset(deg, 0, sizeof(deg));
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    adj[x][++deg[x]] = y;
    adj[y][++deg[y]] = x;
  }
  memset(u, 0, sizeof(u));
  int f = 0, r = 1, flag = 0;
  q[1][1] = 1;
  q[1][2] = n;
  pre[1][n][1] = 0;
  u[1][n] = 1;
  while (f < r) {
    f++;
    int x = q[f][1], y = q[f][2];
    for (int i = 1; i <= deg[x]; i++) {
      for (int j = 1; j <= deg[y]; j++) {
        int X = adj[x][i], Y = adj[y][j];
        if (!u[X][Y] && X != Y) {
          u[X][Y] = 1;
          pre[X][Y][1] = x;
          pre[X][Y][2] = y;
          r++;
          q[r][1] = X;
          q[r][2] = Y;
          if (X == n && Y == 1) {
            flag = 1;
            break;
          }
        }
      }
      if (flag) break;
    }
    if (flag) break;
  }
  if (!u[n][1])
    cout << -1 << endl;
  else {
    print(n, 1);
    cout << tot - 1 << endl;
    for (int i = 1; i <= tot; i++) cout << A[i] << " ";
    cout << endl;
    for (int i = 1; i <= tot; i++) cout << B[i] << " ";
    cout << endl;
  }
  return 0;
}
