#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
const int oo = ~0u >> 2, mo = (int)1e9 + 7;
vector<int> p;
vector<pair<int, int> > Ans;
int n;
void opr(int x, int a, int b) {
  int c = 6 - a - b;
  if (x == n) return;
  opr(x + 1, a, c);
  for (int i = 1; i <= p[x]; ++i) Ans.push_back(make_pair(a, b));
  opr(x + 1, c, b);
}
void gen(int x, int a, int b) {
  int c = 6 - a - b;
  if (x == n) return;
  if (x == n - 1) {
    for (int i = 1; i <= p[x] - 1; ++i) Ans.push_back(make_pair(a, c));
    Ans.push_back(make_pair(a, b));
    for (int i = 1; i <= p[x] - 1; ++i) Ans.push_back(make_pair(c, b));
    return;
  }
  if (p[x] == 1)
    opr(x, a, b);
  else {
    opr(x + 1, a, b);
    for (int i = 1; i <= p[x]; ++i) Ans.push_back(make_pair(a, c));
    opr(x + 1, b, a);
    for (int i = 1; i <= p[x]; ++i) Ans.push_back(make_pair(c, b));
    gen(x + 1, a, b);
  }
}
int main() {
  int la = -1;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    int x;
    scanf("%d", &x);
    if (x != la) p.push_back(0), la = x;
    ++p.back();
  }
  n = ((int)(p).size());
  gen(0, 1, 3);
  printf("%d\n", ((int)(Ans).size()));
  for (int i = 0; i <= ((int)(Ans).size()) - 1; ++i)
    printf("%d %d\n", Ans[i].first, Ans[i].second);
}
