#include <bits/stdc++.h>
using namespace std;
string p[320010];
string p2[320010];
int dp[110][110];
int s(int n, int m) {
  if (dp[n][m] != -1) return dp[n][m];
  if (m < 1 || m > n) return dp[n][m] = 0;
  if (m == n || m == 1) return dp[n][m] = 1;
  return dp[n][m] = s(n - 1, m - 1) + m * s(n - 1, m);
}
int n, total[100];
int use[1000];
int tnum = -1;
int cnt = 0;
void gao(int cntt, int num) {
  for (int i = 0; i < cntt; i++) {
    int maxx = -1;
    for (int j = 0; j < num; j++)
      if (p[i][j] - '0' > maxx) maxx = p[i][j] - '0';
    maxx++;
    if (i % 2 == 1) {
      for (int j = 1; j <= maxx; j++) {
        p2[cnt] = p[i];
        p2[cnt++].push_back(j + '0');
      }
      p2[cnt] = p[i];
      p2[cnt++].push_back('0');
    } else {
      p2[cnt] = p[i];
      p2[cnt++].push_back('0');
      for (int j = maxx; j >= 1; j--) {
        p2[cnt] = p[i];
        p2[cnt++].push_back(j + '0');
      }
    }
  }
}
void print(string temp) {
  int maxx = -1;
  for (int i = 0; i < n; i++) {
    int tnum = temp[i] - '0';
    if (tnum > maxx) maxx = tnum;
  }
  for (int i = 0; i <= maxx; i++) {
    if (i == 0)
      printf("{");
    else
      printf(",{");
    bool first = true;
    for (int j = 0; j < n; j++) {
      if (temp[j] != i + '0') continue;
      if (!first) printf(",");
      printf("%d", j + 1);
      first = false;
    }
    printf("}");
  }
  printf("\n");
}
int main() {
  memset(dp, -1, sizeof(dp));
  for (int i = 1; i <= 10; i++) {
    total[i] = 0;
    for (int j = 1; j <= i; j++) total[i] += s(i, j);
  }
  while (scanf("%d", &n) == 1) {
    p[0] = "0";
    for (int i = 2; i <= n; i++) {
      cnt = 0;
      gao(total[i - 1], i - 1);
      for (int j = 0; j < total[i]; j++) p[j] = p2[j];
    }
    printf("%d\n", total[n]);
    for (int i = 0; i < total[n]; i++) print(p[i]);
  }
  return 0;
}
