#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int sv;
int n;
vector<pair<int, int> > sol;
void simple(int iv, int p1, int p3) {
  if (iv == sv) return;
  int p2;
  if (p1 != 1 and p3 != 1)
    p2 = 1;
  else if (p1 != 2 and p3 != 2)
    p2 = 2;
  else
    p2 = 3;
  simple(iv + 1, p1, p2);
  for (int i = 0; i < v[iv]; i++) sol.push_back(pair<int, int>(p1, p3));
  simple(iv + 1, p2, p3);
}
void complejo(int iv, int p1, int p3) {
  if (iv == sv) return;
  int p2;
  if (p1 != 1 and p3 != 1)
    p2 = 1;
  else if (p1 != 2 and p3 != 2)
    p2 = 2;
  else
    p2 = 3;
  if (v[iv] == 1) {
    simple(iv + 1, p1, p2);
    sol.push_back(pair<int, int>(p1, p3));
    simple(iv + 1, p2, p3);
  } else if (iv == sv - 1) {
    for (int i = 0; i < v[iv] - 1; i++) sol.push_back(pair<int, int>(p1, p2));
    sol.push_back(pair<int, int>(p1, p3));
    for (int i = 0; i < v[iv] - 1; i++) sol.push_back(pair<int, int>(p2, p3));
  } else {
    simple(iv + 1, p1, p3);
    for (int i = 0; i < v[iv]; i++) sol.push_back(pair<int, int>(p1, p2));
    simple(iv + 1, p3, p1);
    for (int i = 0; i < v[iv]; i++) sol.push_back(pair<int, int>(p2, p3));
    complejo(iv + 1, p1, p3);
  }
}
int main() {
  cin >> n;
  vector<int> input(n);
  for (int i = 0; i < n; i++) cin >> input[i];
  int count;
  for (int i = 0; i < n; i++) {
    if (i == 0 or input[i] != input[i - 1])
      count = 1;
    else
      count++;
    if (i == n - 1 or input[i] != input[i + 1]) v.push_back(count);
  }
  sv = int(v.size());
  complejo(0, 1, 3);
  cout << int(sol.size()) << endl;
  for (int i = 0; i < int(sol.size()); i++)
    cout << sol[i].first << " " << sol[i].second << endl;
}
