#include <bits/stdc++.h>
using namespace std;
int s[20];
bool r[20];
vector<pair<int, int> > ans;
void Hanoi(int a, int b, int n, bool last) {
  --n;
  if (n < 0) return;
  int c = 6 - a - b;
  if (last && s[n] > 1 && !r[n]) {
    if (n == 0) {
      Hanoi(a, b, n, false);
      for (int i = 1; i < s[n]; ++i) ans.push_back(make_pair(a, c));
      Hanoi(b, c, n, false);
      ans.push_back(make_pair(a, b));
      Hanoi(c, a, n, false);
      for (int i = 1; i < s[n]; ++i) ans.push_back(make_pair(c, b));
      Hanoi(a, b, n, last);
    } else {
      Hanoi(a, b, n, false);
      for (int i = 0; i < s[n]; ++i) ans.push_back(make_pair(a, c));
      r[n] ^= 1;
      Hanoi(b, a, n, false);
      for (int i = 0; i < s[n]; ++i) ans.push_back(make_pair(c, b));
      r[n] ^= 1;
      Hanoi(a, b, n, last);
    }
  } else {
    Hanoi(a, c, n, false);
    for (int i = 0; i < s[n]; ++i) ans.push_back(make_pair(a, b));
    r[n] ^= 1;
    Hanoi(c, b, n, last);
  }
}
int main() {
  int n, t;
  map<int, int> mp;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &t), ++mp[t];
  n = 0;
  for (map<int, int>::const_iterator it = mp.begin(); it != mp.end(); ++it)
    s[n] = it->second, r[n] = false, ++n;
  Hanoi(1, 3, n, true);
  printf("%d\n", (int)ans.size());
  for (int i = 0; i < ans.size(); ++i)
    printf("%d %d\n", ans[i].first, ans[i].second);
  return 0;
}
