#include <bits/stdc++.h>
using namespace std;
template <class _T>
inline void read(_T &_x) {
  int _t;
  bool _flag = false;
  while ((_t = getchar()) != '-' && (_t < '0' || _t > '9'))
    ;
  if (_t == '-') _flag = true, _t = getchar();
  _x = _t - '0';
  while ((_t = getchar()) >= '0' && _t <= '9') _x = _x * 10 + _t - '0';
  if (_flag) _x = -_x;
}
const int maxn = 30;
vector<pair<int, int> > ans;
int d[maxn];
void move(int n, int x, int y, int z, bool rev) {
  if (n == 0) return;
  int now = n;
  while (now && d[now] == d[n]) --now;
  if (!now) {
    if (rev) {
      for (int i = 1; i <= n; ++i) ans.push_back(pair<int, int>(x, y));
    } else {
      for (int i = 1; i < n; ++i) ans.push_back(pair<int, int>(x, z));
      ans.push_back(pair<int, int>(x, y));
      for (int i = 1; i < n; ++i) ans.push_back(pair<int, int>(z, y));
    }
  } else if (now + 1 == n) {
    move(now, x, z, y, 1);
    ans.push_back(pair<int, int>(x, y));
    move(now, z, y, x, 1);
  } else {
    if (!rev) {
      move(now, x, y, z, 1);
      for (int i = 1; i <= n - now; ++i) ans.push_back(pair<int, int>(x, z));
      move(now, y, x, z, 1);
      for (int i = 1; i <= n - now; ++i) ans.push_back(pair<int, int>(z, y));
      move(now, x, y, z, 0);
    } else {
      move(now, x, z, y, 1);
      for (int i = 1; i <= n - now; ++i) ans.push_back(pair<int, int>(x, y));
      move(now, z, y, x, 1);
    }
  }
}
int main() {
  int n;
  read(n);
  for (int i = 1; i <= n; ++i) read(d[i]);
  reverse(d + 1, d + n + 1);
  move(n, 1, 3, 2, 0);
  printf("%d\n", ans.size());
  for (int i = 0; i < (int)ans.size(); ++i)
    printf("%d %d\n", ans[i].first, ans[i].second);
  return 0;
}
