#include <bits/stdc++.h>
using namespace std;
struct nodo {
  int pila;
  int figli;
  int padre;
  nodo() {}
  nodo(int pila, int figli, int padre)
      : pila(pila), figli(figli), padre(padre) {}
};
vector<nodo> V[13];
void print(int x, int N) {
  vector<int> v;
  while (N > 0) {
    v.push_back(V[N][x].pila);
    x = V[N][x].padre;
    N--;
  }
  v.push_back(0);
  reverse(v.begin(), v.end());
  vector<vector<int> > pile;
  vector<int> vuoto;
  pile.push_back(vuoto);
  pile[0].push_back(0);
  for (int i = 1; i < (int)v.size(); i++) {
    if (v[i] >= (int)pile.size()) {
      assert(v[i] == (int)pile.size());
      pile.push_back(vuoto);
    }
    pile[v[i]].push_back(i);
  }
  for (int i = 0; i < (int)pile.size(); i++) {
    cout << "{";
    for (int j = 0; j < (int)pile[i].size() - 1; j++)
      cout << pile[i][j] + 1 << ",";
    cout << pile[i][pile[i].size() - 1] + 1 << "}";
    if (i != (int)pile.size() - 1) cout << ",";
  }
  cout << "\n";
}
void propaga(int x, int liv) {
  if (x % 2 == 0) {
    V[liv + 1].push_back(nodo(0, max(2, V[liv][x].figli), x));
    for (int i = V[liv][x].figli - 1; i >= 1; i--)
      V[liv + 1].push_back(nodo(i, max(i + 2, V[liv][x].figli), x));
  } else {
    for (int i = 1; i <= V[liv][x].figli - 1; i++)
      V[liv + 1].push_back(nodo(i, max(i + 2, V[liv][x].figli), x));
    V[liv + 1].push_back(nodo(0, max(2, V[liv][x].figli), x));
  }
}
int main() {
  int N;
  cin >> N;
  V[0].push_back(nodo(0, 2, -1));
  for (int i = 0; i < N - 1; i++)
    for (int j = 0; j < (int)V[i].size(); j++) propaga(j, i);
  cout << V[N - 1].size() << endl;
  for (int i = 0; i < (int)V[N - 1].size(); i++) print(i, N - 1);
  return 0;
}
