#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > ans[120000], tempAns[120000];
int ansN, tempN;
int main(void) {
  int n;
  scanf("%d", &n);
  vector<int> a;
  a.push_back(1);
  ans[0].push_back(a);
  ansN = 1;
  for (int i = 2; i <= n; i++) {
    tempN = 0;
    a.clear();
    a.push_back(i);
    for (int j = 0; j < ansN; j++) {
      if (j % 2 == 0) {
        for (int k = 0; k < ans[j].size(); k++) {
          tempAns[tempN] = ans[j];
          tempAns[tempN][k].push_back(i);
          tempN++;
        }
        tempAns[tempN] = ans[j];
        tempAns[tempN].push_back(a);
        tempN++;
      } else {
        tempAns[tempN] = ans[j];
        tempAns[tempN].push_back(a);
        tempN++;
        for (int k = ans[j].size() - 1; k >= 0; k--) {
          tempAns[tempN] = ans[j];
          tempAns[tempN][k].push_back(i);
          tempN++;
        }
      }
    }
    for (int j = 0; j < tempN; j++) ans[j] = tempAns[j];
    ansN = tempN;
  }
  printf("%d\n", ansN);
  for (int i = 0; i < ansN; i++) {
    for (int j = 0; j < ans[i].size(); j++) {
      if (j) printf(",");
      printf("{");
      for (int k = 0; k < ans[i][j].size(); k++) {
        if (k) printf(",");
        printf("%d", ans[i][j][k]);
      }
      printf("}");
    }
    printf("\n");
  }
  return 0;
}
