#include <bits/stdc++.h>
using namespace std;
enum { MAXN = 22, MAXD = 5000000 };
int num[MAXN], rev[MAXN];
char buffer[MAXD], *top = buffer;
int cnt = 0;
void output(int a, int c) {
  ++cnt;
  *(top++) = a + '0';
  *(top++) = ' ';
  *(top++) = c + '0';
  *(top++) = '\n';
}
void solveSimple(int m, int a, int c) {
  const int b = 6 - a - c;
  if (m > 0) {
    solveSimple(m - 1, a, b);
    for (int i = 0; i < num[m - 1]; i++) output(a, c);
    rev[m - 1] ^= 1;
    solveSimple(m - 1, b, c);
  }
}
void solve(int m, int a, int c) {
  const int b = 6 - a - c;
  if (m == 1) {
    if (rev[0]) {
      for (int i = 0; i < num[m - 1]; i++) output(a, c);
    } else {
      for (int i = 0; i < num[0] - 1; i++) output(a, b);
      output(a, c);
      for (int i = 0; i < num[0] - 1; i++) output(b, c);
    }
  } else {
    if (num[m - 1] == 1 || rev[m - 1]) {
      solveSimple(m - 1, a, b);
      for (int i = 0; i < num[m - 1]; i++) output(a, c);
      solve(m - 1, b, c);
    } else {
      solveSimple(m - 1, a, c);
      for (int i = 0; i < num[m - 1]; i++) output(a, b);
      solveSimple(m - 1, c, a);
      for (int i = 0; i < num[m - 1]; i++) output(b, c);
      solve(m - 1, a, c);
    }
  }
}
int main() {
  int n;
  scanf("%d", &n);
  int m = 0, r, pr = -1;
  for (int i = 0; i < n; i++) {
    scanf("%d", &r);
    if (r == pr)
      ++num[m - 1];
    else
      num[m++] = 1;
    pr = r;
  }
  reverse(num, num + m);
  memset(rev, 0, sizeof(rev));
  solve(m, 1, 3);
  *top = '\0';
  printf("%d\n%s", cnt, buffer);
  return 0;
}
