#include <bits/stdc++.h>
using namespace std;
const int maxn = 101, maxl = 2000001;
int n;
int num[maxn];
int res;
struct both {
  int x, y;
} ans[maxl];
void work2(int x, int A, int B) {
  int C = A ^ B;
  if (x == n) {
    for (int i = 1; i <= num[x]; ++i) ans[++res] = (both){A, B};
    return;
  }
  work2(x + 1, A, C);
  for (int i = 1; i <= num[x]; ++i) ans[++res] = (both){A, B};
  work2(x + 1, C, B);
}
void work1(int x, int A, int B) {
  int C = A ^ B;
  if (x == n) {
    for (int i = 1; i < num[x]; ++i) ans[++res] = (both){A, C};
    ans[++res] = (both){A, B};
    for (int i = 1; i < num[x]; ++i) ans[++res] = (both){C, B};
    return;
  }
  if (num[x] == 1) {
    work2(x, A, B);
    return;
  }
  work2(x + 1, A, B);
  for (int i = 1; i <= num[x]; ++i) ans[++res] = (both){A, C};
  work2(x + 1, B, A);
  for (int i = 1; i <= num[x]; ++i) ans[++res] = (both){C, B};
  work1(x + 1, A, B);
}
int main() {
  int i, j, k, last;
  scanf("%d", &n);
  for (i = 1, j = 0, last = 0; i <= n; ++i) {
    scanf("%d", &k);
    if (k != last) last = k, ++j;
    ++num[j];
  }
  n = j;
  work1(1, 1, 3);
  printf("%d\n", res);
  for (i = 1; i <= res; ++i) printf("%d %d\n", ans[i].x, ans[i].y);
  return 0;
}
