#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const int mod0 = 1e9 + 7;
const long long mod1 = 998244353;
const long long mod2 = 1e9 + 9;
const long long mod3 = 2147483647;
const int sz = 2 * 1024 * 1024;
const long long inf = 2 * 1024 * 1024 * 1023 - 1;
const long long INF = inf * inf;
const double eps = 1e-6;
void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout.precision(16);
}
string f(vector<int> v) {
  string ans = "{";
  for (int x : v) {
    ans += to_string(x);
    ans += ",";
  }
  ans.pop_back();
  ans += "}";
  return ans;
}
void solve() {
  int n;
  cin >> n;
  vector<vector<vector<int>>> a(n);
  a[0].push_back(vector<int>{0});
  for (int i = 1; i < n; ++i) {
    int idx = 0;
    for (vector<int> v : a[i - 1]) {
      idx++;
      vector<int> v1 = v;
      v1.push_back(0);
      int m = 1 + *max_element((v1).begin(), (v1).end());
      if (idx % 2 == 1) {
        v1.back() = 0;
        a[i].push_back(v1);
        for (int j = m; j > 0; --j) {
          v1.back() = j;
          a[i].push_back(v1);
        }
      } else {
        for (int j = 1; j < m + 1; ++j) {
          v1.back() = j;
          a[i].push_back(v1);
        }
        v1.back() = 0;
        a[i].push_back(v1);
      }
    }
  }
  cout << a.back().size() << '\n';
  for (vector<int> v : a.back()) {
    int N = 1 + *max_element((v).begin(), (v).end());
    vector<vector<int>> p(N);
    for (int i = 0; i < n; ++i) p[v[i]].push_back(i + 1);
    string ans;
    for (int i = 0; i < N; ++i) {
      ans += f(p[i]);
      ans += ",";
    }
    ans.pop_back();
    cout << ans << '\n';
  }
}
bool multitest = false;
int main() {
  init();
  int t = 1;
  if (multitest) cin >> t;
  for (int i = 0; i < t; ++i) solve();
  return 0;
}
