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

#include "random.h"

using namespace std;

const int maxN = 100000;

int n, p[2][maxN];

int main( int argc, char *argv[] ) {
  assert(argc == 3);
  n = atoi(argv[1]);
  initrand(atoi(argv[2]));

  int k = n / 3;

  for (int i = 1; i < 2 * k; ++i) {
    p[0][i] = i - 1;
  }
  p[0][0] = -1;
  for (int i = 2 * k; i < n; ++i) {
    p[0][i] = k;
  }

  for (int i = 0; i < 2 * k - 1; ++i) {
    p[1][i] = i + 1;
  }
  p[1][2 * k - 1] = -1;
  for (int i = 2 * k; i < n; ++i) {
    p[1][i] = k + 1;
  }

  printf("%d\n", n);
  for (int j = 0; j < 2; ++j) {
    for (int i = 0; i < n; ++i) {
      printf("%d%c", p[j][i] + 1, " \n"[i + 1 == n]);
    }
  }
  fprintf(stderr, "<<Зонтик>> второго типа, %d вершин\n", n);
  return 0;
}
