#include <bits/stdc++.h>
using namespace std;
inline int min(int _a, int _b) { return _a < _b ? _a : _b; }
inline int max(int _a, int _b) { return _a > _b ? _a : _b; }
const int inf = 0x3f3f3f3f;
const double eps = 1e-8;
template <class _T>
inline void rd(_T &_a) {
  int _f = 0, _ch = getchar();
  _a = 0;
  while (_ch < '0' || _ch > '9') {
    if (_ch == '-') _f = 1;
    _ch = getchar();
  }
  while (_ch >= '0' && _ch <= '9')
    _a = (_a << 1) + (_a << 3) + _ch - '0', _ch = getchar();
  if (_f) _a = -_a;
}
int n, cnt, lst, a[30], g[30], f[30];
void up(int x, int b, int c, int d) {
  if (x > n) return;
  up(x + 1, b, d, c);
  for (int i = 1; i <= a[x]; ++i) printf("%d %d\n", b, c);
  up(x + 1, d, c, b);
  return;
}
void move(int x, int b, int c, int d) {
  if (a[x] == 1)
    up(x, b, c, d);
  else if (x == n) {
    for (int i = 1; i < a[x]; ++i) printf("%d %d\n", b, d);
    printf("%d %d\n", b, c);
    for (int i = 1; i < a[x]; ++i) printf("%d %d\n", d, c);
  } else {
    up(x + 1, b, c, d);
    for (int i = 1; i <= a[x]; ++i) printf("%d %d\n", b, d);
    up(x + 1, c, b, d);
    for (int i = 1; i <= a[x]; ++i) printf("%d %d\n", d, c);
    move(x + 1, b, c, d);
  }
  return;
}
int main() {
  rd(n);
  lst = 0;
  for (int i = 1, j; i <= n; ++i) {
    rd(j);
    if (j == lst)
      a[cnt]++;
    else
      a[++cnt] = 1;
    lst = j;
  }
  n = cnt;
  g[n] = a[n];
  f[n] = a[n] * 2 - 1;
  for (int i = n - 1; i; --i) {
    g[i] = g[i + 1] * 2 + a[i];
    if (a[i] == 1)
      f[i] = g[i];
    else
      f[i] = g[i + 1] * 2 + a[i] * 2 + f[i + 1];
  }
  printf("%d\n", f[1]);
  move(1, 1, 3, 2);
  return 0;
}
