#include <bits/stdc++.h>
using namespace std;
int n;
vector<vector<int> > pile;
set<vector<vector<int> > > tr;
void print() {
  for (int i = 0; i < pile.size(); ++i) {
    printf("{");
    for (int j = 0; j < pile[i].size(); ++j) {
      printf("%d%c", pile[i][j], j == pile[i].size() - 1 ? '}' : ',');
    }
    printf("%c", i == pile.size() - 1 ? '\n' : ',');
  }
}
long long getf(const int i, const int j) {
  if (i == 0 && j == 0) return 1;
  if (i == 0 || j == 0) return 0;
  return j * getf(i - 1, j) + getf(i - 1, j - 1);
}
void move(const int x, const int s) {
  int ori = 0;
  for (int i = 0; i < pile.size(); ++i) {
    for (int j = 0; j < pile[i].size(); ++j) {
      if (pile[i][j] == x) {
        ori = i;
      }
    }
  }
  pile[ori].erase(find(pile[ori].begin(), pile[ori].end(), x));
  pile[s].push_back(x);
  if (pile[ori].empty()) {
    pile.erase(pile.begin() + ori);
  }
  for (int i = 0; i < pile.size(); ++i) {
    sort(pile[i].begin(), pile[i].end());
  }
  sort(pile.begin(), pile.end());
}
void go(const int x) {
  if (x == n + 1) {
    print();
    return;
  }
  go(x + 1);
  int npos = 0;
  for (int i = 0; i < pile.size(); ++i) {
    for (int j = 0; j < pile[i].size(); ++j) {
      if (pile[i][j] == x) {
        npos = i;
      }
    }
  }
  bool vis[10];
  memset(vis, 0, sizeof(vis));
  int rem;
  vis[rem = pile[npos][0]] = true;
  for (int i = 0; i < pile.size(); ++i) {
    if (pile[i][0] < x && !vis[pile[i][0]]) {
      vis[pile[i][0]] = true;
      move(x, i);
      go(x + 1);
    }
  }
  if (rem == x) {
    return;
  }
  vector<int> tmp;
  pile.push_back(tmp);
  move(x, pile.size() - 1);
  go(x + 1);
}
int main() {
  long long sum[12];
  for (int i = 0; i <= 10; ++i) {
    sum[i] = 0;
    for (int j = 0; j <= i; ++j) {
      sum[i] += getf(i, j);
    }
  }
  scanf("%d", &n);
  vector<int> init;
  for (int i = 1; i <= n; ++i) {
    init.push_back(i);
  }
  cout << sum[n] << endl;
  pile.push_back(init);
  go(1);
  return 0;
}
