#include <bits/stdc++.h>
using namespace std;
struct isEmpty {
  bool operator()(const vector<int>& v) const { return v.empty(); }
};
struct byFirst {
  bool operator()(const vector<int>& a, const vector<int>& b) const {
    return a[0] < b[0];
  }
};
void normalize(vector<vector<int> >& s) {
  s.erase(remove_if(s.begin(), s.end(), isEmpty()), s.end());
  for (int i = 0; i < s.size(); ++i) sort(s[i].begin(), s[i].end());
  sort(s.begin(), s.end(), byFirst());
}
stringstream ss;
int lineno = 0;
void print(const vector<vector<int> >& s) {
  for (int i = 0; i < s.size(); ++i) {
    if (i) ss << ",";
    ss << "{";
    for (int j = 0; j < s[i].size(); ++j) {
      if (j) ss << ",";
      ss << s[i][j];
    }
    ss << "}";
  }
  ++lineno;
  ss << '\n';
}
int main() {
  int n;
  cin >> n;
  vector<vector<int> > cur(1);
  for (int i = 0; i < n; ++i) cur[0].push_back(i + 1);
  set<vector<vector<int> > > vis;
  vis.insert(cur);
  for (;;) {
    print(cur);
    for (int v = 1; v <= n; ++v)
      for (int to = 0; to <= cur.size(); ++to) {
        vector<vector<int> > c2 = cur;
        for (int i = 0; i < c2.size(); ++i)
          c2[i].erase(remove(c2[i].begin(), c2[i].end(), v), c2[i].end());
        if (to == c2.size()) c2.resize(c2.size() + 1);
        c2[to].push_back(v);
        normalize(c2);
        if (vis.insert(c2).second) {
          cur = c2;
          goto next;
        }
      }
    break;
  next:;
  }
  cout << lineno << endl;
  cout << ss.str();
}
