#include <cstdlib>
#include <cstdio>
#include <algorithm>

#include "random.h"

using namespace std;

const int maxN = 100000;

int n, p[2][maxN], q[2][maxN], rq[2][maxN];

int main( int argc, char *argv[] ) {
  assert(argc == 3);
  n = atoi(argv[1]);
  initrand(atoi(argv[2]));
  for (int j = 0; j < 2; ++j) {
    p[j][0] = -1;
    for (int i = 1; i < n; ++i) {
      p[j][i] = R(0, i - 1);
    }
    for (int i = 0; i < n; ++i) {
      int t = R(0, i);
      q[j][i] = i;
      swap(q[j][i], q[j][t]);
    }
    for (int i = 0; i < n; ++i) {
      rq[j][q[j][i]] = i;
    }
  }
  printf("%d\n", n);
  for (int j = 0; j < 2; ++j) {
    for (int i = 0; i < n; ++i) {
      int t = p[j][rq[j][i]];
      if (t == -1) {
        t = 0;
      } else {
        t = q[j][t] + 1;
      }
      printf("%d%c", t, " \n"[i + 1 == n]);
    }
  }
  fprintf(stderr, "Случайный тест, %d вершин%s\n", n, (n == 1 ? "а" : (n < 5 ? "ы" : "")));
  return 0;
}
