#include <bits/stdc++.h>
using namespace std;
int in() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
inline long long lin() {
  long long x;
  scanf("%lld", &x);
  return x;
}
const int maxn = 2e5 + 10;
int a[maxn], cnt[21], ans;
vector<pair<int, int> > op;
int t;
inline void solve(int n, int from, int to, bool rev = 0) {
  if (n == 0) return;
  int other = from ^ to ^ 3;
  if (rev || a[n] == 1) {
    solve(n - 1, from, other, true);
    for (int i = 0; i < a[n]; i++) op.push_back({from, to});
    solve(n - 1, other, to, true);
    return;
  }
  if (n == 1) {
    for (int i = 0; i < a[n] - 1; i++) op.push_back({from, other});
    op.push_back({from, to});
    for (int i = 0; i < a[n] - 1; i++) op.push_back({other, to});
    return;
  }
  solve(n - 1, from, to, 1);
  for (int i = 0; i < a[n]; i++) op.push_back({from, other});
  solve(n - 1, to, from, 1);
  for (int i = 0; i < a[n]; i++) op.push_back({other, to});
  solve(n - 1, from, to, 0);
}
int32_t main() {
  int n = in();
  for (int i = 0; i < n; i++) a[i] = in(), cnt[a[i]]++;
  for (int i = 1; i <= 20; i++)
    if (cnt[i]) {
      a[++t] = cnt[i];
    }
  solve(t, 0, 2);
  cout << op.size() << "\n";
  for (auto x : op) cout << x.first + 1 << " " << x.second + 1 << "\n";
}
