#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > res;
int t[21];
int s[21];
int cnt[21];
int n;
void mv(int x, int dest) {
  for (int i = 0; i < t[x]; ++i) res.push_back(make_pair(s[x], dest));
  ++cnt[x];
  s[x] = dest;
}
void go(int x, int dest) {
  if (x == n) return;
  go(x + 1, 3 - dest - s[x]);
  mv(x, dest);
  go(x + 1, dest);
}
int main() {
  int disks;
  scanf("%d", &disks);
  res.reserve((1 << disks) + 5);
  int prev = -1;
  for (int i = 0; i < disks; ++i) {
    int cur;
    scanf("%d", &cur);
    if (cur != prev) ++n;
    ++t[n - 1];
    prev = cur;
  }
  int cr = 0;
  for (int i = 0; i < n - 1; ++i)
    if (t[i] > 1 && cnt[i] % 2 == 0) {
      go(i + 1, 2);
      mv(i, 1 - cr);
      go(i + 1, cr);
      mv(i, 2);
    } else {
      go(i + 1, 1 - cr);
      mv(i, 2);
      cr = 1 - cr;
    }
  if (cnt[n - 1] % 2 == 0) {
    for (int i = 0; i < t[n - 1] - 1; ++i) res.push_back(make_pair(cr, 1 - cr));
    res.push_back(make_pair(cr, 2));
    for (int i = 0; i < t[n - 1] - 1; ++i) res.push_back(make_pair(1 - cr, 2));
  } else {
    for (int i = 0; i < t[n - 1]; ++i) res.push_back(make_pair(cr, 2));
  }
  printf("%d\n", (int)res.size());
  for (__typeof(res.begin()) it = (res.begin()); it != (res).end(); ++it)
    printf("%d %d\n", it->first + 1, it->second + 1);
}
