#include <bits/stdc++.h>
using namespace std;
int n;
vector<vector<int>> v;
int cnt = 0;
void rec(int ind) {
  if (ind == n + 1) {
    cnt++;
    for (vector<int> curr : v) {
      for (int x : curr) cout << x << " ";
      cout << "| ";
    }
    cout << '\n';
    return;
  }
  v.push_back(vector<int>{ind});
  rec(ind + 1);
  v.pop_back();
  for (int i = 0; i < v.size(); i++) {
    v[i].push_back(ind);
    rec(ind + 1);
    v[i].pop_back();
  }
}
vector<vector<int>> sol[2];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  sol[0] = {vector<int>{0}};
  for (int i = 1; i < n; i++) {
    sol[i % 2].clear();
    for (int j = 0; j < sol[(i - 1) % 2].size(); j++) {
      int m = 0;
      for (int x : sol[(i - 1) % 2][j]) m = max(m, x);
      m++;
      if (j % 2 == 0) {
        sol[i % 2].push_back(sol[(i - 1) % 2][j]);
        sol[i % 2].back().push_back(0);
        for (int append = m; append > 1; append--) {
          sol[i % 2].push_back(sol[(i - 1) % 2][j]);
          sol[i % 2].back().push_back(append);
        }
        sol[i % 2].push_back(sol[(i - 1) % 2][j]);
        sol[i % 2].back().push_back(1);
      } else {
        sol[i % 2].push_back(sol[(i - 1) % 2][j]);
        sol[i % 2].back().push_back(1);
        for (int append = 2; append <= m; append++) {
          sol[i % 2].push_back(sol[(i - 1) % 2][j]);
          sol[i % 2].back().push_back(append);
        }
        sol[i % 2].push_back(sol[(i - 1) % 2][j]);
        sol[i % 2].back().push_back(0);
      }
    }
  }
  cout << sol[(n - 1) % 2].size() << '\n';
  for (vector<int> v : sol[(n - 1) % 2]) {
    int m = 0;
    for (int x : v) m = max(m, x);
    for (int i = 0; i <= m; i++) {
      vector<int> elements;
      for (int j = 0; j < v.size(); j++) {
        if (v[j] == i) elements.push_back(j + 1);
      }
      cout << "{" << elements[0];
      for (int j = 1; j < elements.size(); j++) cout << "," << elements[j];
      cout << "}";
      if (i != m)
        cout << ",";
      else
        cout << '\n';
    }
  }
}
