#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const double EPS = 1e-9;
const double PI = acos(-1.);
const long long LL_INF = 1e17 + 16;
const int INF = 1e9 + 10;
const long long MOD = 1e9 + 7;
const int MAXN = 2e5 + 5;
vector<int> vv;
map<int, int> cnt;
vector<pair<int, int> > ans;
void rec_sol_a(int from, int mid, int to, int ind) {
  if (ind < 0) {
    return;
  }
  rec_sol_a(from, to, mid, ind - 1);
  for (int i = (0); i < (int)(vv[ind]); i++) {
    ans.push_back(make_pair(from, to));
  }
  rec_sol_a(mid, from, to, ind - 1);
}
void rec_sol_b(int from, int mid, int to, int ind) {
  if (vv[ind] == 1) {
    rec_sol_a(from, mid, to, ind);
    return;
  }
  if (ind == 0) {
    for (int i = (0); i < (int)(vv[ind] - 1); i++) {
      ans.push_back(make_pair(from, mid));
    }
    ans.push_back(make_pair(from, to));
    for (int i = (0); i < (int)(vv[ind] - 1); i++) {
      ans.push_back(make_pair(mid, to));
    }
    return;
  }
  rec_sol_a(from, mid, to, ind - 1);
  for (int i = (0); i < (int)(vv[ind]); i++) {
    ans.push_back(make_pair(from, mid));
  }
  rec_sol_a(to, mid, from, ind - 1);
  for (int i = (0); i < (int)(vv[ind]); i++) {
    ans.push_back(make_pair(mid, to));
  }
  rec_sol_b(from, mid, to, ind - 1);
}
void solve() {
  int n;
  scanf("%d", &n);
  for (int i = (0); i < (int)(n); i++) {
    int a;
    scanf("%d", &a);
    cnt[a]++;
  }
  for (__typeof((cnt).begin()) it = (cnt).begin(); it != (cnt).end(); it++) {
    vv.push_back(it->second);
  }
  rec_sol_b(1, 2, 3, (int)(vv).size() - 1);
  printf("%d\n", (int)(ans).size());
  for (int i = (0); i < (int)((int)(ans).size()); i++) {
    printf("%d %d\n", ans[i].first, ans[i].second);
  }
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
}
