#include <bits/stdc++.h>
using namespace std;
vector<int> v[505];
pair<int, int> a[505][505];
bool vis[505][505];
vector<int> ans1, ans2;
int n, m;
void bfs() {
  queue<pair<int, int> > q;
  q.push(make_pair(1, n));
  while (!q.empty()) {
    pair<int, int> pos = q.front();
    q.pop();
    int l, m;
    l = pos.first;
    m = pos.second;
    int i, j, sz = v[l].size(), sz1 = v[m].size();
    int nl, nm;
    for (i = 0; i < sz; i++) {
      nl = v[l][i];
      for (j = 0; j < sz1; j++) {
        nm = v[m][j];
        if (nl == nm) continue;
        if (!vis[nl][nm]) {
          vis[nl][nm] = true;
          a[nl][nm] = make_pair(l, m);
          q.push(make_pair(nl, nm));
          if (nl == n && nm == 1) {
            return;
          }
        }
      }
    }
  }
}
int main() {
  cin >> n >> m;
  int x, y;
  while (m--) {
    scanf("%d %d", &x, &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  int i, j;
  bfs();
  x = n, y = 1;
  a[1][n] = make_pair(0, 0);
  while (a[x][y].first) {
    ans1.push_back(x);
    ans2.push_back(y);
    pair<int, int> p = a[x][y];
    x = p.first;
    y = p.second;
  }
  if (ans1.size()) {
    int sz = ans1.size();
    printf("%d\n", sz);
    printf("1");
    for (i = sz - 1; i >= 0; i--) {
      printf(" %d", ans1[i]);
    }
    printf("\n%d", n);
    for (i = sz - 1; i >= 0; i--) {
      printf(" %d", ans2[i]);
    }
    printf("\n");
  } else {
    printf("-1\n");
  }
  return 0;
}
