#include <bits/stdc++.h>
using namespace std;
bool bit(int mask, int pos) { return (mask >> pos) & 1; }
vector<int> cycles[11];
void build(int n) {
  if (n == 1) {
    cycles[n] = {0, 1};
    return;
  }
  build(n - 1);
  for (int x : cycles[n - 1]) {
    cycles[n].push_back(x << 1);
  }
  vector<int> t = cycles[n - 1];
  reverse((t).begin(), (t).end());
  for (int x : t) {
    cycles[n].push_back((x << 1) + 1);
  }
}
void sor(vector<int>& a) {
  sort((a).begin(), (a).end(), [&](int x, int y) {
    for (int i = 0;; ++i) {
      if (bit(x, i)) {
        return true;
      }
      if (bit(y, i)) {
        return false;
      }
    }
    return false;
  });
}
void del(vector<int>& rem, int pos) {
  vector<int> ans = {rem[0]};
  for (int i = 1; i < (int)(rem).size(); ++i) {
    int val = rem[i];
    if (bit(val, pos)) {
      val ^= (1 << pos);
    }
    if (val) {
      ans.push_back(val);
    }
  }
  sor(ans);
  rem.swap(ans);
}
void shift(vector<int>& a, int p) {
  vector<int> b;
  for (int i = p; i < (int)(a).size(); ++i) {
    b.push_back(a[i]);
  }
  for (int i = 0; i < p; ++i) {
    b.push_back(a[i]);
  }
  a.swap(b);
}
vector<vector<int> > rec(vector<int> a, vector<int> rem) {
  int n = (int)(a).size();
  if (n == 0) {
    return {{}};
  }
  int start = rem[0];
  if (n == 1) {
    return {{1 << a[0]}};
  }
  vector<int> c = cycles[n - 1];
  for (int i = 0; i < (int)(c).size(); ++i) {
    c[i] = (c[i] << 1) + 1;
  }
  int s = -1;
  for (int i = 0; i < (int)(c).size(); ++i) {
    if (c[i] == start) {
      s = i;
    }
  }
  assert(s != -1);
  shift(c, s);
  vector<vector<int> > ans;
  for (int i = 0; i < (int)(c).size(); ++i) {
    vector<int> newId(n, -1);
    vector<int> alive;
    int z = 0;
    assert(rem[0] == c[i]);
    for (int j = 0; j < n; ++j) {
      if (bit(c[i], j)) {
        continue;
      }
      newId[j] = z++;
      alive.push_back(j);
    }
    vector<int> tmp;
    for (int j = 1; j < (int)(rem).size(); ++j) {
      int val = 0;
      for (int k = 0; k < n; ++k) {
        if (bit(rem[j], k)) {
          val |= (1 << newId[k]);
        }
      }
      tmp.push_back(val);
    }
    vector<vector<int> > vct = rec(alive, tmp);
    for (int j = 0; j < (int)(vct).size(); ++j) {
      vector<int> v = {c[i]};
      for (int val : vct[j]) {
        v.push_back(val);
      }
      ans.push_back(v);
    }
    rem = ans.back();
    if (i + 1 < (int)(c).size()) {
      int pos;
      for (int j = 0; j < n; ++j) {
        if (bit(c[i + 1], j) != bit(c[i], j)) {
          pos = j;
        }
      }
      if ((c[i + 1] & c[i]) == c[i]) {
        rem[0] = c[i + 1];
        del(rem, pos);
      } else {
        rem[0] = c[i + 1];
        rem.push_back(1 << pos);
        sor(rem);
      }
    }
  }
  for (int i = 0; i < (int)(ans).size(); ++i) {
    for (int j = 0; j < (int)(ans[i]).size(); ++j) {
      int val = 0;
      for (int k = 0; k < n; ++k) {
        if (bit(ans[i][j], k)) {
          val |= (1 << a[k]);
        }
      }
      ans[i][j] = val;
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  build(n);
  vector<int> rem;
  int start = 0;
  vector<int> alive;
  for (int i = 0; i < n; ++i) {
    start |= (1 << i);
    alive.push_back(i);
  }
  rem.push_back(start);
  vector<vector<int> > ans = rec(alive, rem);
  cout << (int)(ans).size() << "\n";
  for (int i = 0; i < (int)(ans).size(); ++i) {
    for (int j = 0; j < (int)(ans[i]).size(); ++j) {
      if (j) {
        cout << ',';
      }
      cout << '{';
      bool out = false;
      for (int k = 0; k < n; ++k) {
        if (bit(ans[i][j], k)) {
          if (out) {
            cout << ',';
          }
          cout << k + 1;
          out = true;
        }
      }
      cout << '}';
    }
    cout << "\n";
  }
}
