#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const int lim = 1000000000;
const int maxn = 20;
int n;
int p[maxn], f[maxn][maxn];
struct Seq {
  int p[10];
  Seq() { memset(p, 0, sizeof(p)); }
};
vector<Seq> s[11];
vector<int> len[11];
void Print(Seq t) {
  for (int i = 0; i < n; ++i) {
    bool flag = false;
    for (int j = 0; j < n; ++j)
      if (t.p[j] == i) {
        flag = true;
        break;
      }
    if (!flag) break;
    if (i != 0) putchar(',');
    putchar('{');
    flag = false;
    for (int j = 0; j < n; ++j)
      if (t.p[j] == i) {
        if (flag) putchar(',');
        printf("%d", j + 1);
        flag = true;
      }
    putchar('}');
  }
  putchar('\n');
}
int main() {
  scanf("%d", &n);
  s[0].push_back(Seq());
  len[0].push_back(1);
  memset(f, 0, sizeof(f));
  f[1][1] = 1;
  for (int i = 2; i <= 10; ++i)
    for (int j = 1; j <= i; ++j) f[i][j] = j * f[i - 1][j] + f[i - 1][j - 1];
  int sum = 0;
  for (int i = 1; i <= n; ++i) sum += f[n][i];
  printf("%d\n", sum);
  for (int k = 1; k < n; ++k) {
    bool flag = true;
    for (int i = 0; i < ((int)((s[k - 1]).size())); ++i) {
      int l = len[k - 1][i];
      Seq t = s[k - 1][i];
      if (flag) {
        for (int now = 0; now <= l; ++now) {
          t.p[k] = now;
          s[k].push_back(t);
          if (now == l)
            len[k].push_back(l + 1);
          else
            len[k].push_back(l);
        }
        flag = false;
      } else {
        for (int now = l; now >= 0; --now) {
          t.p[k] = now;
          s[k].push_back(t);
          if (now == l)
            len[k].push_back(l + 1);
          else
            len[k].push_back(l);
        }
        flag = true;
      }
    }
  }
  for (int i = 0; i < ((int)((s[n - 1]).size())); ++i) {
    Print(s[n - 1][i]);
  }
  return 0;
}
