#include <cassert>
#include <cstdio>

#include <algorithm>

using std::next_permutation;

int main() {
  assert(freopen("cipher.in", "r", stdin));
  assert(freopen("cipher.out", "w", stdout));

  int n;
  assert(scanf("%d", &n) == 1);

  int a[n - 1], r = 1;
  for (int i = 0; i < n - 1; i++) {
    a[i] = i;
    r *= i + 1;
  }

  int ans[r * (2 * n - 1)], k = 0;
  do {
    for (int i = 0; i < n - 1; i++)
      ans[k++] = a[i] + 1;
    ans[k++] = n;
    for (int i = 0; i < n - 1; i++)
      ans[k++] = a[i] + 1;
  } while (next_permutation(a, a + n - 1));

  printf("%d\n", k);
  for (int i = 0; i < k; i++)
    printf("%d%c", ans[i], "\n "[i < k - 1]);

  return 0;
}

