#include <bits/stdc++.h>
using namespace std;
vector<int> List, Cnt;
vector<pair<int, int> > Ans;
void simpleMove(int idx, int from, int to, int mid, bool care);
void advanceMove(int idx, int from, int to, int mid, bool care);
void process(int idx, int from, int to, int mid, bool care);
int main() {
  int i, N, cnt = 0, x, bef;
  scanf("%d", &N);
  for (i = 0; i < (int)(N); i++) {
    scanf("%d", &x);
    if (i != 0 && x != bef) {
      List.push_back(cnt);
      Cnt.push_back(0);
      cnt = 0;
    }
    cnt++;
    bef = x;
  }
  List.push_back(cnt);
  Cnt.push_back(0);
  reverse(List.begin(), List.end());
  reverse(Cnt.begin(), Cnt.end());
  process(((int)List.size()) - 1, 1, 3, 2, true);
  printf("%d\n", ((int)Ans.size()));
  for (i = 0; i < (int)(((int)Ans.size())); i++)
    printf("%d %d\n", Ans[i].first, Ans[i].second);
  return 0;
}
void simpleMove(int idx, int from, int to, int mid, bool care) {
  int i;
  process(idx - 1, from, mid, to, false);
  Cnt[idx] = (Cnt[idx] + 1) % 2;
  for (i = 0; i < (int)(List[idx]); i++) Ans.push_back(make_pair(from, to));
  process(idx - 1, mid, to, from, care);
}
void advanceMove(int idx, int from, int to, int mid, bool care) {
  int i;
  if (idx == 0) {
    for (i = 0; i < (int)(List[idx] - 1); i++)
      Ans.push_back(make_pair(from, mid));
    Ans.push_back(make_pair(from, to));
    for (i = 0; i < (int)(List[idx] - 1); i++)
      Ans.push_back(make_pair(mid, to));
  } else {
    process(idx - 1, from, to, mid, false);
    Cnt[idx] = (Cnt[idx] + 1) % 2;
    for (i = 0; i < (int)(List[idx]); i++) Ans.push_back(make_pair(from, mid));
    process(idx - 1, to, from, mid, false);
    Cnt[idx] = (Cnt[idx] + 1) % 2;
    for (i = 0; i < (int)(List[idx]); i++) Ans.push_back(make_pair(mid, to));
    process(idx - 1, from, to, mid, care);
  }
}
void process(int idx, int from, int to, int mid, bool care) {
  if (idx < 0) return;
  if (care) {
    if (List[idx] == 1 || Cnt[idx] == 1)
      simpleMove(idx, from, to, mid, care);
    else
      advanceMove(idx, from, to, mid, care);
  } else {
    simpleMove(idx, from, to, mid, care);
  }
}
