#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
queue<string> Q;
vector<int> adj[11];
int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  Q.push("0");
  int k = 1, len = 1, m;
  string st;
  while ((int)Q.front().length() < n) {
    st = Q.front();
    Q.pop();
    if ((int)st.length() > len) {
      len++;
      k = 1;
    }
    m = *(max_element(st.begin(), st.end())) - '0' + 1;
    if (k % 2) {
      Q.push(st + '0');
      for (int i = m; i >= 1; i--) {
        Q.push(st + (char)('0' + i));
      }
    } else {
      for (int i = 1; i <= m; i++) {
        Q.push(st + (char)('0' + i));
      }
      Q.push(st + '0');
    }
    k++;
  }
  cout << Q.size() << "\n";
  string ans;
  while (!Q.empty()) {
    st = Q.front();
    Q.pop();
    for (int i = 0; i < (int)st.length(); i++) {
      adj[st[i] - '0'].push_back(i + 1);
    }
    ans = "{" + to_string(adj[0][0]);
    for (int j = 1; j < (int)adj[0].size(); j++) {
      ans += "," + to_string(adj[0][j]);
    }
    adj[0].clear();
    ans += "}";
    for (int i = 1; adj[i].size(); i++) {
      ans += ",{" + to_string(adj[i][0]);
      for (int j = 1; j < (int)adj[i].size(); j++) {
        ans += "," + to_string(adj[i][j]);
      }
      adj[i].clear();
      ans += "}";
    }
    cout << ans << "\n";
  }
  return 0;
}
