#include <bits/stdc++.h>
using namespace std;
const int N = 20 + 5;
const int inf = 0x3f3f3f3f;
inline void getint(int& num) {
  char c;
  bool flag = 0;
  num = 0;
  while ((c = getchar()) < '0' || c > '9')
    if (c == '-') flag = 1;
  while (c >= '0' && c <= '9') {
    num = num * 10 + c - 48;
    c = getchar();
  }
  if (flag) num = -num;
}
int n, R[N], same[N];
long long f[N], g[N];
inline int other(int i, int j) {
  if (i > j) swap(i, j);
  if (i == 1)
    return j == 2 ? 3 : 2;
  else if (i == 2)
    return j == 1 ? 3 : 1;
  else
    return j == 1 ? 2 : 1;
}
void dfs(int x, int A, int C, bool flag) {
  if (x < 1) return;
  int B = other(A, C), m = same[x];
  if (flag) {
    if (f[x] == 2 * g[x - 1] + 1) {
      dfs(x - 1, A, B, 0);
      printf("%d %d\n", A, C);
      dfs(x - 1, B, C, 0);
    } else {
      dfs(x - m, A, C, 0);
      for (int i = 1; i <= m; i++) printf("%d %d\n", A, B);
      dfs(x - m, C, A, 0);
      for (int i = 1; i <= m; i++) printf("%d %d\n", B, C);
      dfs(x - m, A, C, 1);
    }
  } else {
    dfs(x - m, A, B, 0);
    for (int i = 1; i <= m; i++) printf("%d %d\n", A, C);
    dfs(x - m, B, C, 0);
  }
}
int main() {
  getint(n);
  for (int i = 1; i <= n; i++) getint(R[n - i + 1]);
  for (int i = 1; i <= n; i++)
    for (int j = i; j >= 1; j--) {
      if (R[j] == R[i])
        same[i]++;
      else
        break;
    }
  for (int i = 1; i <= n; i++) {
    int m = same[i];
    g[i] = g[i - m] + m + g[i - m];
    f[i] = min(2 * g[i - 1] + 1, 2 * g[i - m] + 2 * m + f[i - m]);
  }
  cout << f[n] << '\n';
  dfs(n, 1, 3, 1);
}
