#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
const int res[10] = {1, 2, 5, 15, 52, 203, 877, 4140, 21147, 115975};
int n;
int m;
int x[10];
int c[10];
int go(int i, int j) {
  if (i == n) {
    for (int k = 0; k < j; k++) {
      if (k > 0) printf(",");
      printf("{");
      int f = 1;
      for (int l = 0; l < n; l++)
        if (x[l] == k) {
          if (!f) printf(",");
          f = 0;
          printf("%d", l + 1);
        }
      printf("}");
    }
    printf("\n");
    return 0;
  }
  int q = c[i];
  c[i] ^= 1;
  for (int l = 0; l <= j; l++) {
    int k = l;
    if (q) k = j - l;
    x[i] = k;
    go(i + 1, j + int(k == j));
  }
  return 0;
}
int main() {
  scanf("%d", &n);
  x[0] = 0;
  printf("%d\n", res[n - 1]);
  go(1, 1);
  return 0;
}
