#include <bits/stdc++.h>
int n, d, ld, cnt, a[21], ans, X[1 << 20], Y[1 << 20];
void __U(int x, int A, int B) {
  if (x + 1 == cnt) {
    for (int i = 0; i < a[x]; i++) X[ans] = A, Y[ans++] = B;
  } else {
    int C = 6 - A - B;
    __U(x + 1, A, C);
    for (int i = 0; i < a[x]; i++) X[ans] = A, Y[ans++] = B;
    __U(x + 1, C, B);
  }
}
void __C(int x, int A, int B) {
  int C = 6 - A - B;
  if (x + 1 == cnt) {
    for (int i = 1; i < a[x]; i++) X[ans] = A, Y[ans++] = C;
    X[ans] = A;
    Y[ans++] = B;
    for (int i = 1; i < a[x]; i++) X[ans] = C, Y[ans++] = B;
  } else if (a[x] == 1)
    __U(x, A, B);
  else {
    __U(x + 1, A, B);
    for (int i = 0; i < a[x]; i++) X[ans] = A, Y[ans++] = C;
    __U(x + 1, B, A);
    for (int i = 0; i < a[x]; i++) X[ans] = C, Y[ans++] = B;
    __C(x + 1, A, B);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &d);
    if (d == ld)
      a[cnt - 1]++;
    else
      ld = d, a[cnt++] = 1;
  }
  __C(0, 1, 3);
  printf("%d\n", ans);
  for (int i = 0; i < ans; i++) printf("%d %d\n", X[i], Y[i]);
}
