#include <bits/stdc++.h>
int N, i, j, Ans;
int X[25], p[25], Cnt[25];
int Q[4][25], res1[1048576], res2[1048576];
void dfs(int N, int A, int B, int C) {
  int i, p;
  if (!N) return;
  if (N == 1) {
    p = Q[A][Q[A][0]];
    for (i = 1; i <= Cnt[p]; ++i) res1[++Ans] = A, res2[Ans] = C;
    Q[C][++Q[C][0]] = p, --Q[A][0];
    return;
  }
  dfs(N - 1, A, C, B);
  p = Q[A][Q[A][0]];
  for (i = 1; i <= Cnt[p]; ++i) res1[++Ans] = A, res2[Ans] = C;
  Q[C][++Q[C][0]] = p, --Q[A][0];
  dfs(N - 1, B, A, C);
}
int main() {
  scanf("%d", &N);
  for (i = 1; i <= N; ++i) {
    scanf("%d", &X[i]);
    ++Cnt[X[i]];
  }
  for (i = 1; i <= N; i += Cnt[X[i]]) {
    for (j = 1; j <= 20; ++j) p[j] = 0;
    for (j = 1; j <= 3; ++j) Q[j][0] = 0;
    p[X[i]] = 1;
    for (j = i + 1; j <= N; ++j)
      if (!p[X[j]]) {
        p[X[j]] = 1;
        Q[1][++Q[1][0]] = X[j];
      }
    if (!Q[1][0]) {
      for (j = 1; j < Cnt[X[i]]; ++j) res1[++Ans] = 1, res2[Ans] = 2;
      res1[++Ans] = 1, res2[Ans] = 3;
      for (j = 1; j < Cnt[X[i]]; ++j) res1[++Ans] = 2, res2[Ans] = 3;
    } else if (Cnt[X[i]] == 1) {
      dfs(Q[1][0], 1, 3, 2);
      res1[++Ans] = 1, res2[Ans] = 3;
      dfs(Q[2][0], 2, 1, 3);
      break;
    } else {
      dfs(Q[1][0], 1, 2, 3);
      for (j = 1; j <= Cnt[X[i]]; ++j) res1[++Ans] = 1, res2[Ans] = 2;
      dfs(Q[3][0], 3, 2, 1);
      for (j = 1; j <= Cnt[X[i]]; ++j) res1[++Ans] = 2, res2[Ans] = 3;
    }
  }
  printf("%d\n", Ans);
  for (i = 1; i <= Ans; ++i) printf("%d %d\n", res1[i], res2[i]);
  return 0;
}
