#include <bits/stdc++.h>
using namespace std;
inline void write(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) write(x / 10);
  putchar(x % 10 + 48);
}
int n;
bool vis[15];
void output(vector<int> &s) {
  memset(vis, 0, sizeof vis);
  for (bool flag = 1;;) {
    int u = -1;
    for (int i = (int)0, _y = s.size() - 1; i <= _y; i++)
      if (!vis[s[i]]) {
        vis[u = s[i]] = 1;
        break;
      }
    if (u == -1) break;
    vector<int> t;
    for (int i = (int)0, _y = s.size() - 1; i <= _y; i++)
      if (s[i] == u) t.push_back(i + 1);
    if (flag)
      flag = 0;
    else
      putchar(',');
    putchar('{');
    for (int i = (int)0, _y = t.size() - 1; i <= _y; i++)
      write(t[i]), putchar(i == (int)t.size() - 1 ? '}' : ',');
  }
  puts("");
}
int main() {
  scanf("%d", &n);
  vector<vector<int> > x;
  vector<int> t;
  t.push_back(0);
  x.push_back(t);
  for (int i = (int)2, _y = n; i <= _y; i++) {
    vector<vector<int> > y;
    for (int j = (int)0, _y = x.size() - 1; j <= _y; j++) {
      int mx = 0;
      for (int k = (int)0, _y = x[j].size() - 1; k <= _y; k++)
        mx = max(mx, x[j][k]);
      mx++;
      vector<int> t = x[j];
      if (j & 1) {
        for (int k = (int)1, _y = mx; k <= _y; k++)
          t = x[j], t.push_back(k), y.push_back(t);
        t = x[j];
        t.push_back(0);
        y.push_back(t);
      } else {
        t.push_back(0);
        y.push_back(t);
        for (int k = (int)mx, _y = 1; k >= _y; k--)
          t = x[j], t.push_back(k), y.push_back(t);
      }
    }
    x = y;
  }
  printf("%d\n", (int)x.size());
  for (int i = (int)0, _y = x.size() - 1; i <= _y; i++) output(x[i]);
}
