#include <bits/stdc++.h>
using namespace std;
const int maxN = 20 + 5;
int n;
int d[maxN];
vector<pair<int, int> > ans;
inline void unOrder(int s, int e, int start, int end, int mid) {
  if (d[s] == d[e]) {
    for (int i = s; i <= e; i++) ans.push_back(pair<int, int>(start, end));
    return;
  }
  int poi = s;
  while (d[s] == d[poi]) poi++;
  unOrder(poi, e, start, mid, end);
  for (int i = s; i < poi; i++) ans.push_back(pair<int, int>(start, end));
  unOrder(poi, e, mid, end, start);
}
inline void order(int s, int e, int start, int end, int mid) {
  if (d[s] == d[e]) {
    for (int i = s + 1; i <= e; i++) ans.push_back(pair<int, int>(start, mid));
    ans.push_back(pair<int, int>(start, end));
    for (int i = s + 1; i <= e; i++) ans.push_back(pair<int, int>(mid, end));
    return;
  }
  if (d[s] != d[s + 1]) {
    unOrder(s, e, start, end, mid);
    return;
  }
  int poi = s;
  while (d[s] == d[poi]) poi++;
  unOrder(poi, e, start, end, mid);
  for (int i = s; i < poi; i++) ans.push_back(pair<int, int>(start, mid));
  unOrder(poi, e, end, start, mid);
  for (int i = s; i < poi; i++) ans.push_back(pair<int, int>(mid, end));
  order(poi, e, start, end, mid);
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> d[i];
  order(1, n, 1, 3, 2);
  cout << ans.size() << endl;
  for (int i = 0; i < (int)ans.size(); i++)
    cout << ans[i].first << ' ' << ans[i].second << endl;
  return 0;
}
