#include <bits/stdc++.h>
using namespace std;
bool Output;
int doit(int op, vector<int> a, int p0, int p1, int p2) {
  if (((int)(a).size()) == 0) return 0;
  int ret = 0;
  if (op == 1) {
    if (a[0] == 1) {
      ret += doit(2, a, p0, p1, p2);
    } else if (a.size() == 1) {
      ret += a[0] * 2 - 1;
      if (Output) {
        for (int _ = (1); _ <= (a[0] - 1); _++) cout << p0 << " " << p1 << endl;
        cout << p0 << " " << p2 << endl;
        for (int _ = (1); _ <= (a[0] - 1); _++) cout << p1 << " " << p2 << endl;
      }
    } else {
      int x = a[0];
      a.erase(a.begin());
      ret += doit(2, a, p0, p1, p2);
      ret += x;
      if (Output) {
        for (int _ = (1); _ <= (x); _++) cout << p0 << " " << p1 << endl;
      }
      ret += doit(2, a, p2, p1, p0);
      ret += x;
      if (Output) {
        for (int _ = (1); _ <= (x); _++) cout << p1 << " " << p2 << endl;
      }
      ret += doit(1, a, p0, p1, p2);
    }
  } else {
    int x = a[0];
    a.erase(a.begin());
    ret += doit(2, a, p0, p2, p1);
    ret += x;
    if (Output) {
      for (int _ = (1); _ <= (x); _++) cout << p0 << " " << p2 << endl;
    }
    ret += doit(2, a, p1, p0, p2);
  }
  return ret;
}
int main() {
  int n0;
  cin >> n0;
  int last = -1;
  vector<int> a;
  while (n0--) {
    int x;
    cin >> x;
    if (last != x)
      a.push_back(1);
    else
      a.back()++;
    last = x;
  }
  Output = 0;
  cout << doit(1, a, 1, 2, 3) << endl;
  Output = 1;
  doit(1, a, 1, 2, 3);
  return 0;
}
