//#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>
#define mp make_pair
#define pb push_back

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", clock()*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, clock()*1.0/CLOCKS_PER_SEC)

#if ( _WIN32 || __WIN32__ )
    #define LLD "%I64d"
#else
    #define LLD "%lld"
#endif

using namespace std;

#define TASKNAME "cipher"

#ifdef LOCAL
static struct __timestamper {
	~__timestamper(){
        TIMESTAMP(end);
	}
} __TIMESTAMPER;
#endif

typedef long long ll;
typedef long double ld;


int n;
int val[10];


int main(){
    freopen(TASKNAME".in","r",stdin);
    freopen(TASKNAME".out","w",stdout);
   
    scanf("%d",&n);
    for (int i = 0; i < n; i++)
    	val[i] = i+1;

    int f = 2*n;
    for (int i = 1; i < n; i++)
    	f *= i;
    printf("%d\n", f);

    do {
    	for (int i = 0; i < n; i++)
    		printf("%d ", val[i]);
    	for (int i = 0; i < n; i++)
    		printf("%d ", val[i]);
    } while (next_permutation(val+1, val + n));

      
  return 0;
}