#include <bits/stdc++.h>
using namespace std;
int f[12][12];
vector<vector<vector<int> > > res[2];
int main() {
  int n;
  int i, j;
  f[1][1] = 1;
  for (i = 1; i <= 9; i++)
    for (j = 1; j <= i; j++) {
      f[i + 1][j + 1] += f[i][j];
      f[i + 1][j] += f[i][j] * j;
    }
  cin >> n;
  int ans = 0;
  for (i = 1; i <= n; i++) ans += f[n][i];
  printf("%d\n", ans);
  vector<int> a;
  a.push_back(1);
  vector<vector<int> > b;
  b.push_back(a);
  res[0].push_back(b);
  for (i = 1, j = 0; i < n; i++, j = (j ^ 1)) {
    res[j ^ 1].clear();
    for (int k = 0, dir = 0; k < res[j].size(); k++, dir = (dir ^ 1)) {
      vector<vector<int> >& now = res[j][k];
      if (dir == 0) {
        vector<vector<int> > next;
        for (int u = 0; u < now.size(); u++) {
          next = res[j][k];
          next[u].push_back(i + 1);
          res[j ^ 1].push_back(next);
        }
        next = res[j][k];
        a.clear();
        a.push_back(i + 1);
        next.push_back(a);
        res[j ^ 1].push_back(next);
      } else {
        vector<vector<int> > next = res[j][k];
        a.clear();
        a.push_back(i + 1);
        next.push_back(a);
        res[j ^ 1].push_back(next);
        for (int u = now.size() - 1; u >= 0; u--) {
          next = res[j][k];
          next[u].push_back(i + 1);
          res[j ^ 1].push_back(next);
        }
      }
    }
  }
  for (i = 0; i < res[j].size(); i++) {
    vector<vector<int> >& now = res[j][i];
    for (int k = 0; k < now.size(); k++) {
      if (k > 0) printf(",");
      vector<int>& cur = now[k];
      printf("{");
      for (int u = 0; u < cur.size(); u++) {
        if (u > 0) printf(",");
        printf("%d", cur[u]);
      }
      printf("}");
    }
    printf("\n");
  }
  return 0;
}
