#include <bits/stdc++.h>
using namespace std;
const int maxn = 30;
int n, A[maxn];
namespace Ninit {
int a[maxn];
void init() {
  int i, m;
  scanf("%d", &m);
  for (i = 1; i <= m; ++i) {
    scanf("%d", a + i);
    a[i] != a[i - 1] ? A[++n] = 1 : ++A[n];
  }
  reverse(A + 1, A + n + 1);
}
}  // namespace Ninit
namespace Nsolve {
int N, B[2100000];
void M(int a, int b, int K) {
  int i;
  for (i = 0; i < K; ++i) B[N++] = a + b * 3;
}
void G(int x, int a, int b) {
  int c = 3 - a - b;
  if (x == 1) return M(a, b, A[x]);
  G(x - 1, a, c), M(a, b, A[x]), G(x - 1, c, b);
}
void F(int x, int a, int b) {
  int c = 3 - a - b;
  if (A[x] == 1) return G(x, a, b);
  if (x == 1) return M(a, c, A[x] - 1), M(a, b, 1), M(c, b, A[x] - 1);
  G(x - 1, a, b), M(a, c, A[x]), G(x - 1, b, a), M(c, b, A[x]), F(x - 1, a, b);
}
void solve() {
  int i;
  F(n, 0, 2);
  printf("%d\n", N);
  for (i = 0; i < N; ++i) printf("%d %d\n", B[i] % 3 + 1, B[i] / 3 + 1);
}
}  // namespace Nsolve
int main() {
  Ninit::init();
  Nsolve::solve();
  return 0;
}
