#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0;
  char ch = getchar();
  bool positive = 1;
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') positive = 0;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
  return positive ? x : -x;
}
const int MaxN = 10000007;
int ans1[MaxN], ans2[MaxN], cnt[25], a[25], len, N, n;
void add(int x, int y) { ans1[++len] = x, ans2[len] = y; }
void DFS(int dep, int a, int b, int c) {
  if (dep == N) {
    for (int i = 1; i <= cnt[dep]; i++) add(a, b);
    return;
  }
  DFS(dep + 1, a, c, b);
  for (int i = 1; i <= cnt[dep]; i++) add(a, b);
  DFS(dep + 1, c, b, a);
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = 1; i <= n; i++)
    if (a[i] == a[i - 1])
      cnt[N]++;
    else
      cnt[++N] = 1;
  for (int i = 1; i <= N; i++) {
    if (i == N) {
      for (int j = 1; j < cnt[i]; j++) add(1, 2);
      add(1, 3);
      for (int j = 1; j < cnt[i]; j++) add(2, 3);
    } else if (cnt[i] == 1) {
      DFS(i + 1, 1, 2, 3);
      add(1, 3);
      DFS(i + 1, 2, 3, 1);
      break;
    } else {
      DFS(i + 1, 1, 3, 2);
      for (int j = 1; j <= cnt[i]; j++) add(1, 2);
      DFS(i + 1, 3, 1, 2);
      for (int j = 1; j <= cnt[i]; j++) add(2, 3);
    }
  }
  printf("%d\n", len);
  for (int i = 1; i <= len; i++) printf("%d %d\n", ans1[i], ans2[i]);
  return 0;
}
