#include <bits/stdc++.h>
using namespace std;
vector<int> ht[3];
vector<pair<int, int> > ans;
int a[22];
void Move(int n, int x, int y) {
  if (!n) return;
  for (int i = 0, _n(n); i < _n; ++i) ans.push_back(pair<int, int>(x, y));
  ht[y].push_back(n);
  if (n == ht[x].back())
    ht[x].pop_back();
  else
    ht[x].back() -= n;
}
void DisorderMove(int n, int x, int y) {
  int ass;
  if (x + y == 2)
    ass = 1;
  else if (x + y == 1)
    ass = 2;
  else
    ass = 0;
  if (n == 1) {
    Move(ht[x].back(), x, y);
  } else {
    DisorderMove(n - 1, x, ass);
    Move(ht[x].back(), x, y);
    DisorderMove(n - 1, ass, y);
  }
}
void OrderMove(int n, int x, int y) {
  int ass;
  if (x + y == 2)
    ass = 1;
  else if (x + y == 1)
    ass = 2;
  else
    ass = 0;
  int si = ht[x].size();
  if (si == 1) {
    int t = ht[x].back() - 1;
    Move(t, x, ass);
    Move(1, x, y);
    Move(t, ass, y);
  } else if (ht[x][si - n] == 1) {
    DisorderMove(n, x, y);
  } else {
    DisorderMove(n - 1, x, y);
    DisorderMove(1, x, ass);
    DisorderMove(n - 1, y, x);
    DisorderMove(1, ass, y);
    OrderMove(n - 1, x, y);
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 0, _n(n); i < _n; ++i) cin >> a[i];
  a[n] = -1;
  int cnt = 1;
  for (int i = 0, _n(n); i < _n; ++i) {
    if (a[i] != a[i + 1])
      ht[0].push_back(cnt), cnt = 1;
    else
      cnt++;
  }
  OrderMove(ht[0].size(), 0, 2);
  cout << ans.size() << endl;
  for (int i = 0, _n(ans.size()); i < _n; ++i)
    printf("%d %d\n", ans[i].first + 1, ans[i].second + 1);
  return 0;
}
