#include <bits/stdc++.h>
using namespace std;
vector<string> ans[11];
int N, sc, sd;
vector<int> f[20];
int main() {
  scanf("%d", &N);
  ans[1].push_back("0");
  for (int i = 2; i <= N; i++) {
    for (int j = 0; j < ans[i - 1].size(); j++) {
      sc = 0;
      string st = ans[i - 1][j];
      for (int k = 0; k < st.size(); k++)
        if (st[k] - 48 > sc) sc = st[k] - 48;
      sc++;
      if (j % 2 == 0) {
        ans[i].push_back(st + "0");
        for (int k = sc; k >= 1; k--) ans[i].push_back(st + char(k + 48));
      } else {
        for (int k = 1; k <= sc; k++) ans[i].push_back(st + char(k + 48));
        ans[i].push_back(st + "0");
      }
    }
  }
  cout << ans[N].size() << endl;
  for (int i = 0; i < ans[N].size(); i++) {
    for (int j = 0; j <= N; j++) f[j].clear();
    sc = 0;
    for (int j = 0; j < N; j++) {
      sd = ans[N][i][j] - 48;
      sc = max(sc, sd);
      f[sd].push_back(j + 1);
    }
    for (int j = 0; j <= sc; j++) {
      printf("{%d", f[j][0]);
      for (int k = 1; k < f[j].size(); k++) printf(",%d", f[j][k]);
      printf("}");
      if (j != sc) printf(",");
    }
    printf("\n");
  }
  return 0;
}
