#include <bits/stdc++.h>
using namespace std;
int n;
vector<vector<vector<int> > > rec(int n) {
  if (n == 1)
    return vector<vector<vector<int> > >(
        1, vector<vector<int> >(1, vector<int>(1, 1)));
  vector<vector<vector<int> > > res;
  vector<vector<vector<int> > > pred = rec(n - 1);
  vector<int> x(1, n);
  for (int i = 0; i < pred.size(); i++)
    if ((i & 1) == 0) {
      for (int j = 0; j < pred[i].size(); j++) {
        res.push_back(pred[i]);
        res[res.size() - 1][j].push_back(n);
      }
      res.push_back(pred[i]);
      res[res.size() - 1].push_back(x);
    } else {
      res.push_back(pred[i]);
      res[res.size() - 1].push_back(x);
      for (int j = pred[i].size() - 1; j >= 0; j--) {
        res.push_back(pred[i]);
        res[res.size() - 1][j].push_back(n);
      }
    }
  return res;
}
int main() {
  scanf("%d", &n);
  vector<vector<vector<int> > > res = rec(n);
  printf("%d\n", res.size());
  for (int i = 0; i < res.size(); i++) {
    for (int j = 0; j < res[i].size(); j++) {
      if (j > 0) printf(",");
      printf("{");
      for (int k = 0; k < res[i][j].size(); k++) {
        if (k > 0) printf(",");
        printf("%d", res[i][j][k]);
      }
      printf("}");
    }
    printf("\n");
  }
  return 0;
}
