#include <bits/stdc++.h>
using namespace std;
int n, a[30];
vector<pair<int, int> > ans;
int other(int a, int b) {
  if (a > b) swap(a, b);
  if ((a == 1) && (b == 2)) return 3;
  if ((a == 1) && (b == 3)) return 2;
  if ((a == 2) && (b == 3)) return 1;
  return 0;
}
void search(int l, int r, int n, int flag) {
  int t = other(l, r), k = n;
  while ((k > 1) && (a[k - 1] == a[k])) --k;
  if (flag == 0) {
    if (k == n)
      search(l, r, n, 1);
    else if (k == 1) {
      for (int i = 1; i < n; i++) ans.push_back(make_pair(l, t));
      ans.push_back(make_pair(l, r));
      for (int i = 1; i < n; i++) ans.push_back(make_pair(t, r));
    } else {
      search(l, r, k - 1, 1);
      for (int i = 1; i <= n - k + 1; i++) ans.push_back(make_pair(l, t));
      search(r, l, k - 1, 1);
      for (int i = 1; i <= n - k + 1; i++) ans.push_back(make_pair(t, r));
      search(l, r, k - 1, 0);
    }
  } else {
    if (k == 1) {
      for (int i = 1; i <= n; i++) ans.push_back(make_pair(l, r));
    } else {
      search(l, t, k - 1, 1);
      for (int i = 1; i <= n - k + 1; i++) ans.push_back(make_pair(l, r));
      search(t, r, k - 1, 1);
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = n; i >= 1; i--) scanf("%d", &a[i]);
  search(1, 3, n, 0);
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++)
    printf("%d %d\n", ans[i].first, ans[i].second);
  return 0;
}
