#include <bits/stdc++.h>
using namespace std;
int n, res;
int p[20];
vector<int> g[20];
void solve(int x, int c) {
  if (x == n) {
    for (int i = 1; i <= c; i++) g[i].clear();
    for (int i = 0; i < n; i++) g[p[i]].push_back(i + 1);
    for (int i = 1; i <= c; i++)
      if (g[i].size()) {
        cout << '{';
        for (int j = 0; j < g[i].size(); j++) {
          cout << g[i][j];
          if (j + 1 < g[i].size()) cout << ',';
        }
        cout << '}';
        if (i < c) cout << ',';
      }
    cout << endl;
    return;
  }
  p[x] = min(c + 1, p[x]);
  solve(x + 1, max(c, p[x]));
  int par = p[x];
  for (int i = 1; i <= c + 1; i++)
    if (i != par) {
      p[x] = i;
      solve(x + 1, max(i, c));
    }
}
int Count(int x, int c) {
  if (x == n) return 1;
  int res = c * Count(x + 1, c) + Count(x + 1, c + 1);
  return res;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) p[i] = 1;
  cout << Count(0, 0) << endl;
  solve(1, 1);
  return 0;
}
