#include <bits/stdc++.h>
using namespace std;
const int MaxN = 12, MaxC = 0x3F3F3F3F, NA = -1;
int a[MaxN];
int n;
void out(void) {
  int i, j, m;
  bool f;
  m = -1;
  for (i = 0; i < n; i++) m = max(m, a[i]);
  m++;
  for (i = 0; i < m; i++) {
    if (i > 0) putchar(',');
    putchar('{');
    f = false;
    for (j = 0; j < n; j++)
      if (a[j] == i) {
        if (f) putchar(',');
        f = true;
        printf("%d", j + 1);
      }
    putchar('}');
  }
  putchar('\n');
}
void recur(int d) {
  if (d == n) {
    out();
    return;
  }
  int i, m;
  m = -1;
  for (i = 0; i < d; i++) m = max(m, a[i]);
  m++;
  if (a[d] == 0)
    for (i = 0; i <= m; i++) {
      a[d] = i;
      recur(d + 1);
    }
  else
    for (i = m; i >= 0; i--) {
      a[d] = i;
      recur(d + 1);
    }
}
int recurcount(int d) {
  if (d == n) return 1;
  int i, m, res;
  res = 0;
  m = -1;
  for (i = 0; i < d; i++) m = max(m, a[i]);
  m++;
  for (i = 0; i <= m; i++) {
    a[d] = i;
    res += recurcount(d + 1);
  }
  return res;
}
int main(void) {
  while (scanf(" %d", &n) != EOF) {
    memset(a, 0, sizeof(a));
    printf("%d\n", recurcount(0));
    memset(a, 0, sizeof(a));
    recur(0);
  }
  return 0;
}
