#include <bits/stdc++.h>
int move, x[25], a[25], output1[10000000], output2[10000000], tail;
int other(int A, int B) {
  for (int i = 1; i <= 3; i++)
    if (i != A && i != B) return i;
}
void U(int s, int t, int A, int B) {
  if (s == t) {
    for (int i = 1; i <= x[s]; i++) output1[++tail] = A, output2[tail] = B;
    move += x[s];
    return;
  }
  U(s + 1, t, A, other(A, B));
  for (int i = 1; i <= x[s]; i++) output1[++tail] = A, output2[tail] = B;
  move += x[s];
  U(s + 1, t, other(A, B), B);
}
void C(int s, int t, int A, int B) {
  int i;
  if (s == t) {
    for (i = 1; i <= x[s] - 1; i++)
      output1[++tail] = A, output2[tail] = other(A, B);
    output1[++tail] = A, output2[tail] = B;
    for (i = 1; i <= x[s] - 1; i++)
      output1[++tail] = other(A, B), output2[tail] = B;
    move += 2 * x[s] - 1;
    return;
  }
  if (x[s] == 1) {
    U(s, t, A, B);
    return;
  }
  U(s + 1, t, A, B);
  for (i = 1; i <= x[s]; i++) output1[++tail] = A, output2[tail] = other(A, B);
  move += x[s];
  U(s + 1, t, B, A);
  for (i = 1; i <= x[s]; i++) output1[++tail] = other(A, B), output2[tail] = B;
  move += x[s];
  C(s + 1, t, A, B);
}
int main() {
  int i, n, cur, m = 0;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (i == 1 || a[i] != a[i - 1]) {
      m++;
      if (m > 1) x[m - 1] = i - cur;
      cur = i;
    }
  }
  x[m] = n + 1 - cur;
  C(1, m, 1, 3);
  printf("%d\n", move);
  for (i = 1; i <= tail; i++) printf("%d %d\n", output1[i], output2[i]);
}
